Re: [xsl] position() function in loop provides only 1

Subject: Re: [xsl] position() function in loop provides only 1
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 11 Apr 2012 14:23:47 +0100
On 11 April 2012 14:08, henry human <henry_human@xxxxxxxx> wrote:
> I now that the position() reset after a loop is ended and I am not expecting
some thing else .
> In my case the position () provides correctly the POSITION for each loop in
the FIRST loop but
> in the other loop (xsl:for-each select="taxtotal) the position() function
provides ever ONE and does not increment!!!

The position() function isn't 'reset' or 'incremented', its simply the
position on the nodes in the list of nodes you have selected to
process.

For example:

<foo>
  <bar/>
  <bar/>
</foo>

if <foo> is the context node and you do <xsl:apply-templates/> that is
equivalent to <xsl:apply-templates select="child::node()"/> which will
select the 5 child nodes of foo:

1 whitespace
2 <bar/>
3 whitesapce
4 <bar/>
5 whitespace

...so when you call position() in the <bar/> matching template you
will get 2 or 4, because that is the position of the node within the
node list you selected to process


> Regarding number function I do not now how to use it here. and I think you
are wrong, in XSLT you cant save value to a variable and use it global!

Nice... xsl:number is an instruction not a function, it has nothing to
do variables, and is the right thing to use here.



--
Andrew Welch
http://andrewjwelch.com

Current Thread