Most of my experience is in converting xml to html. I'm in new waters now in an attemt to transform xml to xml. It's fine until i try to convert to an element with attributes. Then i get stuck, and i've gone through several XML books trying to figure out a way past this. Here's what i have
old xml sample
I want it to convert to
i wrote the following: but it, of course, does not validate since < is not a valid value to have inside a name.
I found xsl:element and xsl:attribute but i can't find anything that shows me how to combine the two. Suggestions?
old xml sample
XML:
<rootElement>
<Variables>
<Variable name="varname" value="varvalue" />
</Variables>
</rootElement>
I want it to convert to
XML:
<rootElement>
<Data><Var name="varname">varvalue</Var></Data>
</rootElement>
i wrote the following: but it, of course, does not validate since < is not a valid value to have inside a name.
Code:
<xsl:template match="Variables">
<Data>
<xsl:for-each select="Variable">
<Var name="<xsl:value-of select="@name" />"><xsl:value-of select="@value" /></Var>
</xsl:for-each>
</Data>
</xsl:template>
I found xsl:element and xsl:attribute but i can't find anything that shows me how to combine the two. Suggestions?