Reputation: 133
I have an XML document and I want to rename some elements via XSLT:
<Assert @some attributes here>
<conent>
<And>
<formula>
<Atom>
<opr>
...
For example I want to rename <opr>
to <op>
. I have the following XSLT:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="opr">
<op>
<xsl:apply-templates select="@*|node()"/>
</op>
</xsl:template>
When I debug the XSLT it just doesn't go inside the "opr" template, it gets matched by the first template. The generated output is the same as the input. Can anyone help me on this?
Upvotes: 1
Views: 3264
Reputation: 2148
Does this work?
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:copy>
</xsl:template>
<xsl:template match="opr">
<op>
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</op>
</xsl:template>
Upvotes: 0
Reputation: 8336
<xsl:template name="YourNameHere">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="opr">
<op>
<xsl:call-template name="YourNameHere"/>
</op>
</xsl:template>
You'll probably still need something like <xsl:template match="/" /> to get it going.
Upvotes: 1