Subject: [xsl] Return position in for-each From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 22 Jul 2004 15:45:40 -0700 |
Hello, A disadvantage to an xsl:for-each is that the position() increases by one for each step. so, if an xsl:if test validates the current step and says "Yes apply templates for this step", "don't apply templates for this step", and you are interested in a positiion which reflects the total number of "YES" steps... well you have a problem. Take into consideration this for-each rule: <xsl:for-each select="Entry"> <xsl:variable name="element_name"><xsl:value-of select="concat('competitor_name_',position())"/></xsl:variable> <xsl:if test="string($BROWSER_VARS//ELEMENT[@name=$element_name]/.)"> <tr> <!-- [[[ HERE WE ADD A COLUMN THAT HAS AN INCREMENTING NUMBER ]]] --> <td><xsl:value-of select="concat(position(),'.')"/></td> <!-- [[[ HERE WE GET THE REST OF THE COLUMN DATA ]]] --> <xsl:apply-templates select="Element" mode="PRINTER_FRIENDLY"> <xsl:with-param name="position"><xsl:value-of select="position()"/></xsl:with-param> </xsl:apply-templates> </tr> </xsl:if> </xsl:for-each> Is there a work-around, or another way to accomplish an incrementing number for the TD? Karl
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Indent?, Michael Kay | Thread | RE: [xsl] Return position in for-ea, Michael Kay |
RE: [xsl] Infinite Loop when param , Michael Kay | Date | RE: [xsl] Infinite Loop when param , Karl J. Stubsjoen |
Month |