Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

position()

Syntax

Description

Return the current context position among the list of nodes that are currently being evaluated. The context position is the index of the node within the node-set being evaluated by a predicate, or if position() is being used outside of a predicate, then it is the index of the current node within the current node list. The initial position is 1 and the final position is equal to the context size, which can be retrieved through the last() function.

Usage Examples

The following op script shows the effect of using the position() function in both location path predicates as well as within for-each loops.