Top

Name

position — Returns the context position from expression evaluation context.

Synopsis

number position ( void);  
 

Description

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.

Examples

Example 24.609. Explicit call of position() inside a predicate

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

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

Example 24.610. Implicit call of position() inside a predicate

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

//article/section[1]/paragraph[position()<=3]

See Also

last() count()