I have an XML input with elements that have a number of attributes. I don't know in advance, which attributes.
I'd like to create an attribute element of the same name for each of the existing attributes.
Input:
<elem id="1" name="test" version="2" />
<elem id="2" check="true" base="dir"/>
output:
<newelem newattribute="bla" newattribute2="blabla" id="1" name="test" version="2"/>
<newelem newattribute="bla" newattribute2="blabla" id="2" check="true" base="dir"/>
I tried this:
<xsl:for-each select="@*">
<xsl:attribute name="name(.)" select="."/>
</xsl:for-each>
But the name() function doesn't work here, it seems.
What's the right way to do this?