Re: [xsl] Counting using variable inside the loop

Subject: Re: [xsl] Counting using variable inside the loop
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 11 Mar 2004 09:32:23 +0000
Hi Arulraj,

> But I want to make a count row, when I reach first row I should this
> is first row. when next row encounter I should say this is second
> row.

Use <xsl:number> (no need to specify any attributes) to give you these
numbers, or calculate them yourself by counting the number of
preceding sibling rows to the current one, and adding one, with:

  count(preceding-sibling::row) + 1

> I tried with <xsl:variable>

You can't change the value of a variable in XSLT (it's a declarative
language rather than a procedural one). If you were stepping through
the <row> elements one by one, you could use a parameter to keep track
of them, but usually one of the above methods works fine.



Jeni Tennison

 XSL-List info and archive:

Current Thread