position — Returns the context position from expression evaluation context.


number position ( void);


Context position is the number of nodes in the node-set where the context node comes from. For the most popular case, when position() is used inside a predicate, and the predicate relates to some axis of the path, position() is the number of calls of the predicate, including the "current" call which is in progress when the function is called. Thus, context position cannot be greater than context size.

Return Types

Positive integer.


Example24.609.Explicit call of position() inside a predicate

For every waybill, find the last <address> child inside the <waybill> element.

//waybill/address[position() = last()]

Example24.610.Implicit call of position() inside a predicate

For every article, find up to three first paragraphs of the first section.


See Also

last() count()