XSLT store xml in an attribute

Deuce

New Member
I have a variable in my xslt that looks like this.\[code\]<xsl:variable name="metadata"> <Metadata> <xsl:apply-templates select="..." /> </Metadata></xsl:variable>\[/code\]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.\[code\]<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>\[/code\]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,Fahed
 
Back
Top