About Node Positions

The node positions for a node set start with 1. Evaluation of the position number is always based on document order. For example, the following query returns the first author element in the current context:

author[1] 
               

            

The next query finds the author elements (in the current context) that contain a first-name element. The query returns the third such author element.

(author[first-name])[position()=3] 
               

            

When you specify an integer in brackets, it is equivalent to calling the position() function. For example, the following queries both return the third y child element of each x child element in the current context:

x/y[3]
               
x/y[position()=3]
               

            

Tip: If you do not know the position of the node you want, a call to the position() function might help you. See Determining the Position Number of a Node.

The return value of the position() function depends on the specified axis. For example, suppose the axis is one of the reverse axes, such as preceding, ancestor, or preceding-sibling. The position() function returns the nth one in reverse document order that falls in the specified axis.

XML-DEV Discussion Forum

XML-DEV is a leading technical forum for XML discussion and a valuable free XML learning resource. Subscribe to the XML-DEV email discussion forum today to help further your XML education.

XML Schema Designer

The XML Schema Designer is a tool for accelerating advanced XML Schema development through an intuitive visual interface for modeling any XML data structures.

XML Development Blogs

Blogging is the hottest fad on the Internet and Stylus Studio has jumped on the bandwagon. Bookmark these XML Blogs to keep up with all the latest XML buzz in the internet blogosphere. Includes RSS and Atom Feeds!

XQuery Tools Support for TigerLogic XDMS

Stylus Studio's integration with the TigerLogic XDMS XQuery processor, allowing you to execute advanced XQuery expressions directly against any TigerLogic XDMS instance.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member