This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How do I get the name of the current node


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]