Subject: Numbering - For each
Posted By: Navy1991_1 Post Date: 7/2/2008 5:46:10 AM
Is there a way to number all rows in a for-each statement?  I don't need to produce a count, however I need to have the following output.

1       black
2       red
3       green

I need to generate the 1, 2, 3... next to the values.

Reply By: samjudson Reply Date: 7/2/2008 5:50:42 AM
The xpath function position() will give you the position in a for-each loop.

/- Sam Judson : Wrox Technical Editor -/
Reply By: mhkay Reply Date: 7/2/2008 6:30:15 AM
The simplest way is <xsl:value-of select="position()"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: Navy1991_1 Reply Date: 7/2/2008 7:56:21 AM
Thank you!


Go to topic 72443

Return to index page 1