I have a variable in my xslt that looks like this.
<xsl:variable name="metadata">
<Metadata>
<xsl:apply-templates select="..." />
</Metadata>
</xsl:variable>
Afterwards, I'm trying to add the metadata xml as an xsl:attribute to another node. I tried value-of, copy-of and it didn't work. When using copy-of, I got the error below.
<OtherNode>
<xsl:attribute name="someAttr">
<!-- I tried these and neither worked -->
<xsl:value-of select="$metadata" /> <!-- Empty -->
<xsl:copy-of select="$metadata" /> <!-- Error -->
</xsl:attribute>
</OtherNode>
An item of type 'Element' cannot be constructed within a node of type 'Attribute'.
That's fairly straight forward, but for some reason, I thought it would automatically escape the element.
I'm using xslt 1.0 by the way.
Any ideas?
Thanks