position
The current context position
Description
The fn:position function returns an integer representing the position (starting with 1, not 0) of the current context item within the context sequence (the current sequence of items being processed.
Examples
XPath |
Results |
Explanation |
---|---|---|
$in-xml/*[position() > 2] |
<a>3</a> <a>4</a> <a>5</a> |
|
$in-xml/a[position() > 2] |
<a>4</a> <a>5</a> |
|
$in-xml/a[position() = 3] |
<a>4</a> |
The expression [position() = 3] is equivalent to the expression [3]. |
XPath |
Results |
---|---|
$in-xml/*[position() > 2] |
<a>3</a> <a>4</a> <a>5</a> |
$in-xml/a[position() > 2] |
<a>4</a> <a>5</a> |
$in-xml/a[position() = 3] |
<a>4</a> |