[xslt] ancestor-or-self question



Hi,

I want to transform the following XML:

<root>
<level1>
        <level2>a</level2>
        <level2>b</level2>
        ...
</level1>
</root>

to the following XML:

<root>
<level1>
        <level2>other_value</level2>
</level1>
</root>


for that I was hoping I could use use something like that:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml"/>
        <xsl:template match="/">
             <xsl:copy-of select="/root/level1/level2[1]/ancestor-or-self::*"/>
        </xsl:template>
</xsl:stylesheet>

Which of course doesn'I work (I use xsltproc version 1.1.21) spent a whole day trying to figure it out and browsed all web resources I could find, I'm at a loss.

Many thanks in advance, Vincent.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]