xsl-list
[Top] [All Lists]

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

2012-04-11 08:24:02
On 11 April 2012 14:08, henry human <henry_human(_at_)yahoo(_dot_)de> 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 can’t 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--