Subject: RE: Renaming One Element in a XML document using XSL
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Feb 2005 14:23:14 -0000
|
> So I want to copy all the document and rename certain nodes.
> How can I do
> this??
The standard mechanism for "I want to copy all the document except..." is to
use an identity template
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/><xsl:apply-templates/>
</xsl:copy>
</xsl:template>
and then override it for elements you want to change:
<xsl:template match="Pooh">
<xsl:element name="Piglet">
<xsl:copy-of select="@*"/><xsl:apply-templates/>
</xsl:element>
</xsl:template>
Michael Kay
http://www.saxonica.com/
|