This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How do I get the name of the current node
- To: XSL-List at mulberrytech dot com
- Subject: How do I get the name of the current node
- From: Mike Clarke <Mike dot Clarke at Xitec-Software dot com>
- Date: Thu, 26 Oct 2000 16:04:16 +0100
- Reply-To: xsl-list at mulberrytech dot com
I think I've missed something fairly fundamental, which I'm sure you'll all
spot in a second.
I want to use <xsl:choose> to identify nodes in a result set. For example
for the XML
<assembly>
<sprogit sku="180" colour="blue" />
<dofer sku="094401" kind="fluffy" />
<sprogit sku="1094" colour="pink" />
<widget sku="999" legs="5" />
<dofer sku="000801" kind="crispy" />
</assembly>
I thought I could write some simple XSL that could handle each element of
the assembly :
<xsl:for-each select="assembly/*">
<xsl:choose>
<xsl:when test="./sprogit">
<td> <xsl:value-of select="@sku"/> </td><td> 0
</td><td> <xsl:value-of select="@colour"/><td> Hard </td>
</xsl:when>
<xsl:when test="./widget">
<td> <xsl:value-of select="@sku"/> </td><td>
<xsl:value-of select="@legs"/> </td> grey <td> <td> Hard </td>
</xsl:when>
<xsl:when test="./dofer">
<td> <xsl:value-of select="@sku"/> </td><td> 0 </td>
grey <td> <td> <xsl:value-of select="@kind"/> </td>
</xsl:when>
</xsl:choose>
However the individual when's never get executed. I've tried several
different approaches and I've looked in all the XSL resources and I can only
find examples that match attributes or strings. How do I match the name of
the node ?
Regards
Mike C
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list