Pages

Showing posts with label position(). Show all posts
Showing posts with label position(). Show all posts

Monday, September 9, 2013

Get Position of the current Node in Xslt



You can get the value of a current node using in-built function "position()".


Check position of the current node



<xsl:value-of select=”position()” />        
<xsl:value-of select=”root/item[position()]” />      <!--and  u can use-->   



Check the first node:


<xsl:for-each select="root/items">
 <xsl:choose>
       <xsl:when test="position()='1'">                              <!-- check the first node-->
         <xsl:value-of select="'this is the first node'" />
       </xsl:when>


       <xsl:otherwise>
         <xsl:value-of select="'this is not the first node'" />
       </xsl:otherwise>
 </xsl:choose>
</xsl:for-each>