tags:

views:

76

answers:

2

I have a xsl file for html output. the xsl handles an old format of xml whixh I want to renew now. Therefore I need to rename the old elements names to the new names I'm using the new names in the following xsl code. How can I do this? I tried

<xsl:template match="OldName">
<NewName><xsl:value-of select="."/></NewName>
</xsl:template>
<xsl:template match="/">
some code... </xsl:template>

and then I tried to access

<xsl:value-of select="NewName"/>

but got nothing while when using the OldName I got the value

A: 

<xsl:value-of select="NewName"/> looks at the input, not the output. And in the input, there is no NewName. To make use of the NewName, you would have to parse it twice; once renewing the names, and once doing formatting.

Eric
+1  A: 

If you're using XSLT2, you can use a two-phase transformation.

Pete Kirkham
In XSLT 1, you can do multi-phase transformations like this if you have the `node-set()` extension function available. See http://www.xml.com/pub/a/2003/07/16/nodeset.html
Jukka Matilainen