I would do it as a two-step operation.
Step1.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <root> <xsl:apply-templates select="attribute/value" /> </root> </xsl:template> <xsl:template match="value"> <object> <xsl:value-of select="." disable-output-escaping="yes" /> </object> </xsl:template> </xsl:stylesheet>
to create intermediate XML:
<root> <object> <map> <item> <src>something</src> <dest>something else</dest> </item> </map> </object> </root>
Step2.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="object"> <table> <tr> <xsl:for-each select="map/item/*"> <th> <xsl:value-of select="name()" /> </th> </xsl:for-each> </tr> <tr> <xsl:for-each select="map/item/*"> <td> <xsl:value-of select="." /> </td> </xsl:for-each> </tr> </table> </xsl:template> </xsl:stylesheet>
to create an HTML table
<table> <tr> <th>src</th> <th>dest</th> </tr> <tr> <td>something</td> <td>something else</td> </tr> </table>
source share