I am transforming one XML into another. Let's say the XML we start from looks like this
<fruit id="123">
<apple></apple>
<banana></banana>
<lemon></lemon>
</fruit>
Now in my transformed XML I want to create a new attribute with the value of the id attribute from my old XML.
I tried to do this like this:
<xsl:template match="fruit">
<xsl:attribute name="reference">
<xsl:value-of select="fruit/@id"/>
</xsl:attribute>
</xsl:template>
I get this error:
cannot create an attribute node whose parent is a document node
Can somebody explain to me what I'm doing wrong, since I don't understand the error. A solution would be nice.
Thank you!