Loading ...
Sorry, an error occurred while loading the content.

Re: delete all but first occurence of a pattern

Expand Messages
  • Nikolaos A. Patsopoulos
    ... I m currently looking for sth that will work with VI (I use vim script files). As last resort I ll try your suggestion though. Thank you for your reply,
    Message 1 of 3 , Apr 2, 2007
    • 0 Attachment
      Tobia wrote:
      > I don't think Vim's regular expressions are the best tool for this job.
      > I mean, XML manipulation is much easier done in XSLT:
      >
      > <?xml version="1.0"?>
      > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      > <xsl:template match="article">
      > <xsl:copy>
      > <xsl:copy-of select="@*"/>
      > <AuthorList CompleteYN="Y">
      > <Author ValidYN="Y">
      > <xsl:copy-of select="AuthorList/Author[1]/*"/>
      > </Author>
      > </AuthorList>
      > <xsl:copy-of select="node()[not(self::AuthorList)]"/>
      > </xsl:copy>
      > </xsl:template>
      > </xsl:stylesheet>
      >
      > This does what you want in your example, assuming the source is a proper
      > XML document (among other things there must be a "root tag" encompassing
      > all the articles.) Invoke with "xsltproc fix-authors.xsl articles.xml"
      > or with any other XSLT tool.
      >
      >
      > To get back on-topic, I find these scripts make working with XSLT a bit
      > less painful:
      >
      > xslhelper.vim http://www.vim.org/scripts/script.php?script_id=1364
      > closetag.vim http://www.vim.org/scripts/script.php?script_id=13
      >
      > This, on the other hand, is on my list of "things to check", but I still
      > haven't got around to checking it out:
      >
      > xml.vim http://www.vim.org/scripts/script.php?script_id=1397
      >
      >
      > Tobia
      >
      >
      >
      I'm currently looking for sth that will work with VI (I use vim script
      files). As last resort I'll try your suggestion though.

      Thank you for your reply,

      Nikos
    Your message has been successfully submitted and would be delivered to recipients shortly.