copy-of without the element tag
Hi all,
I need to copy several elements but sometimes add an attribute into the element tag as well. The attribute to look for in the source is always the same and should be copied into a class attribute in the target. Then all contents of the source should be copied into the element. I have tried to achieve this as follows:
<xsl:template match="p|note|propval|strow">
<xsl:element name="{local-name()}">
<xsl:if test="@version!=''">
<xsl:attribute name="class">
<xsl:value-of select="@version"/>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="."/>
</xsl:element>
</xsl:template>
This gives me an element with the correct class attribute, but with a nested element that has the original stuff in it. So for every <p> I get a <p> with a nested <p>.
If I use <xsl:value-of select="."/> I lose all the child elements. What option am I missing here?
Thanks in advance for your help
Jang
|