469,917 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

XSLT incrementing count

Hi,
I am new to XSLT. My problem is that I wish to create an HTML table, and
give each row an incrementing number from 1.This would increment every
itteration of a for-each loop.
The XSLT fragment I have tried is:

<xsl:variable name="test" select="0"></xsl:variable>
<table border="1">
<tbody>
<tr bgcolor="#9acd32">
<th>Number</th>
</tr>
<xsl:for-each select="amsal_coverage_stats/core">
<tr>
<td>

<xsl:value-of select="$test+1"></xsl:value-of>

</td>
</tr>
</xsl:for-each>

However this just has the value 1.

Any help would be much appreciated.

Thanks.
John.
Sep 5 '05 #1
2 4747


John Wilkinson wrote:
My problem is that I wish to create an HTML table, and
give each row an incrementing number from 1.This would increment every
itteration of a for-each loop. <xsl:for-each select="amsal_coverage_stats/core">
<tr>
<td>

<xsl:value-of select="$test+1"></xsl:value-of>


You can use
<xsl:value-of select="position()" />

For more advanced stuff you might want to check the <xsl:number> statement.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 5 '05 #2
don't use <xsl:for-each> element, it's terrible. Instead of it
<xsl:apply-templates> with <xsl:value-of select="position()"/> in it.
Sep 6 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Graham | last post: by
5 posts views Thread by inquirydog | last post: by
4 posts views Thread by Chris Kettenbach | last post: by
1 post views Thread by cameron | last post: by
1 post views Thread by jrwarwick | last post: by
reply views Thread by DAnne | last post: by
4 posts views Thread by J | last post: by
4 posts views Thread by shaun roe | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.