Subject: Re: Creating elements in an arbitrary position in the result document
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Mon, 18 Jan 2010 04:05:59 +0100
|
<xsl:template match="A">
<xsl:copy>
<xsl:copy-of select="@*"/>
<new_element attrC="value1" attrD="value2"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
better?
<xsl:template match="A">
<xsl:copy>
<xsl:copy-of select="@*"/>
<new_element>
<xsl:copy-of select=".//B/C/@*" />
<xsl:copy-of select=".//B/C/D/@*" />
<xsl:apply-templates />
</new_element>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes except B-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="B">
<xsl:copy>
<xsl:apply-templates select="@*|node() except (C union D)"/>
</xsl:copy>
</xsl:template>
|