position function
The fn:position function returns the position of the context item in the sequence that is being processed.
Syntax
Returned value
The returned value is an xs:integer value that indicates the position of the context item in the sequence that is currently being processed. If the context item is undefined, an error is returned. The position function returns a deterministic result only if the sequence that contains the context item has a deterministic order. The position function is typically used in a predicate.
Example
In the following expression, the
position function is called for each item in a sequence of ten items.
For each item, the position function returns the position of that
item in the sequence. The predicate position() eq 5
is
true only for the fifth item in the sequence.
(11 to 20)[position() eq 5]
The value returned by the expression is 15.