Click to See Complete Forum and Search --> : add an attribute with XSLT


nickreserved
11-12-2009, 09:44 AM
I want to export an XML with an attribute name="work" to all XML elements.
Here is the XSLT.
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*" />

<xsl:template match="*">
<xsl:attribute name="name">work</xsl:attribute>
<xsl:apply-templates />
<xsl:copy-of select="." />
</xsl:template>

Why this doesn't work?

nickreserved
11-12-2009, 10:10 AM
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:attribute name="name">work</xsl:attribute>
<xsl:apply-templates />
</xsl:copy>