Helpful Information
 
 
Category: Programming Languages More
attributes to nodes in XSL?

I would like to get something like:

<a b="1">
<c d="2">
whatever
</c>
</a>


converted to something like:

<a>
<b>
1
</b>
<c>
<d>
2
</d>
whatever
</c>
</a>


I would like to turn attributes to element nodes, I've come up with a simple XSL to do it but I can only get the values of the attributes but not their names (that are unknown).


thanks in advance.

danig

I've solved it myself, it was only a matter of finding the right function... =)




<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>

</xsl:copy>
</xsl:template>


<xsl:template match="@*">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>