Return position of context item in current sequence.
fn:position => unsignedInt?
This context function returns the position of the context item within the sequence of items that is currently being processed. The function returns the empty sequence if the context is the empty sequence.
Retrieve the first even natural numbers:
let $numbers := ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ) return $numbers[position() mod 2 = 0]
The query returns all those sequence items whose position modulo 2 equals 0, i.e., which is an even number.
The following construct(s) refer to this construct: