Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.


The position function returns a number equal to the context position from the expression evaluation context.

Syntax

position()

Returns

An integer equal to the context position from the expression evaluation context.

Notes

  • Note that a node's position in a context is not zero-based. The first node has a position of 1.
  • The context is determined by the rest of the path.
<xsl:template match="//a[position() = 5]">
 <!-- this template matches the fifth a element 
         anywhere in the document. -->
</xsl:template>
<xsl:template match="//div[@class='foo']/bar[position() = 1]">
 <!-- this template matches the first bar element that is
      a child of a div element with a class attribute equal to "foo" -->
</xsl:template>

Defined

XPath 1.0 4.1

Gecko support

Supported.

Document Tags and Contributors

 Contributors to this page: Sheppy, Mgjbot, Gopireddy, Jake Archibald, Fredchat, Ptak82, Jonnyq
 Last updated by: Sheppy,