Re: [xsl] Resetting Position() in multiple for-each loops

Subject: Re: [xsl] Resetting Position() in multiple for-each loops
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Fri, 24 Mar 2006 16:20:48 +1100
If your source XML has extraneous new lines between elements, it may be picking that up. If you give up what your select statement is, we could probably have a better idea of what is wrong.
G. Ken Holman wrote:


At 2006-03-24 08:13 +0800, rostom aghanian wrote:

I have multiple xsl:for-each loops where I am trying to output the position of
my index in each loop. These xsl:for-each loops are NOT nested. The problem is
that the Position() function does not seem to reset itself once I am done with
one loop and move on to the next. So if my first loop contained 5 items, I will
get 1 through 5 outputted, but then when I start my next loop the Position()
outputs 6, 7, 8, etc. I need it to restart the counter. How would I go about
doing this?


XPath defines the position() function as returning the current node's position in the current context as calculated by the evaluation's context.

This means that each time you do a select= it returns a current node list and your position in that list *always* starts at 1.

According to your evidence, the processor is broken ... perhaps you are misinterpreting what you have from what you are seeing.

I hope this helps.

. . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal




--
Kamal Bhatt

Tourism Technology Pty Ltd


T: +61 (02) 9956 7300 F: +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060



http://www.tt.com.au


Current Thread