home contribute faq download

FunctX XSLT Functions

fn:position

The current context position

Google
Webxsltfunctions.com

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.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameType
return value xs:integer

Examples

<xsl:variable name="in-xml" as="item()*">
<in-xml>
     <a>1</a>
     <c>2</c>
     <a>3</a>
     <a>4</a>
     <a>5</a>
   </in-xml>
</xsl:variable>
XPath ExampleResultsExplanation
$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].

See Also

functx:first-nodeThe XML node in a sequence that appears first in document order
functx:last-nodeThe XML node in a sequence that is last in document order
fn:index-ofThe position(s) of an atomic value within a sequence
fn:lastThe size of the current context

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery