XSLT: How to put the node name into the result?

suppose I have an xml like this:

<?xml version='1.0' standalone='yes' ?>
<G>
<R>
<SUB1>
<AA>blahAA</AA>
<AB>blahAB</AB>
<AC>blahAC</AC>
</SUB1>
<SUB2>
<BA>blahBA</BA>
<BB>blahBB</BB>
</SUB2>
<SUB3>
<CA>blahCA</CA>
<CB>blahCB</CB>
<CC>blahCC</CC>
<CD>blahCD</CD>
</SUB3>
</R>
</G>
</xml>

using XSLT, how would i produce a table in html that looked like:

GROUPA GROUPB SUBGROUP NAME VALUE
G R SUB1 AA blahAA
G R SUB1 AB blahAB
G R SUB1 AC blahAC
G R SUB2 BA blahBA
G R SUB2 BB blahBB
G R SUB3 CA blahCA
G R SUB3 CB blahCB
G R SUB3 CC blahCC
G R SUB3 CD blahCD

thanks in advance
[1131 byte] By [cjard] at [2007-11-19 19:21:43]
# 1 Re: XSLT: How to put the node name into the result?
How to put the node name into the result? The is a xslt function called local-name so maybe you can do something like this:

<xsl:value-of select="local-name(current())"/>

Or simply:

<xsl:value-of select="local-name()"/>

- petter
wildfrog at 2007-11-10 3:27:01 >
# 2 Re: XSLT: How to put the node name into the result?
Note your xml is not well formed. <?xml> is a processing instruction, not an element node. This solution assumes you have an outerlying node around your xml, say <root>.

<xsl:template match="* ">
<xsl:param name="tablerow" select="''"/>
<xsl:apply-templates select="*">
<xsl:with-param name="tablerow">
<xsl:copy-of select="$tablerow"/>
<td>
<xsl:value-of select="local-name(.)"/>
</td>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*[not (*)]">
<xsl:param name="tablerow" select="''"/>
<tr>
<xsl:copy-of select="$tablerow"/>
<td>
<xsl:value-of select="local-name(.)"/>
</td>
</tr>
</xsl:template>
<xsl:template match="/*">
<html>
<body>
<table>
<tr>
<th>GROUPA</th>
<th>GROUPB</th>
<th>SUBGROUP</th>
<th>NAME</th>
<th>VALUE</th>
</tr>
<xsl:apply-templates select="*"/>
</table>
</body>
</html>
</xsl:template>
jkmyoung at 2007-11-10 3:28:12 >