I'm a complete XML newbie and I'm attempting to use an XSLT to transform an
string containing XML so that the nodes are named as per my requirements and
nodes that I don't need arem't written.
Now the renaming of the nodes works but I'm not sure how to not copy the
nodes that I don't want.
Here's the code I'm using to do the existing transformation (posted by Oleg
Tkachenko on the microsoft.public.dotnet.xml ) which as I said works great and I'm sure that all that is
required is a
change to the xsltherwise section but what is the best way to go about it?
should I try another xsl:choose ,xsl:if or something else?
Any help greatly appreciated.
Nathan
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:variable name="rule"
select="document('mapping.xml')/mapping/rule[@inbound=name(current())]"/>
<xsl:choose>
<xsl:when test="$rule">
<xsl:element name="{$rule/@outbound}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsltherwise>
<!-- No mapping - copy as is -->
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsltherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>