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

Reply via email to