[xsl] Fwd: XSLT 2.0 Determining Position of Sequence Item During "for expression" evaluation

Subject: [xsl] Fwd: XSLT 2.0 Determining Position of Sequence Item During "for expression" evaluation
From: "John McGowan" <john@xxxxxxxxxxx>
Date: Fri, 16 Mar 2007 14:08:31 -0500
I'm doing all this with Saxon 8.8J

I have a simple xpath expression like this

for $x in (10 to 20) return $x

which simply return the sequence of integers between 10 and 20

Now, what if I wanted to return something like this instead from the
same sequence

1 2 3 4 ... 11

I want to get access to the "position" of $x in the sequence,  and
also the total number of items in the sequence.

I tried something like this

for $x in (10 to 20) return $x/position()

which failed because $x was an integer, not a node so it couldn't tell
me the position of it... so I tried it out on my "real" code and all
it ever outputted was 1's

The real problem I'm trying to tackle is simply treating the last one
different than all the others to do some special formatting of the
list.  I figured it would be easy enough to do a position()=last()
type check...

--
John McGowan
Seven A C Consulting, Inc.

Current Thread