Determining the Position Number of a Node

The position() function returns an integer that indicates the position of the node within the parent. Positions start with 1; a node with a position of 1 is always the first node in the collection.

For example, the following query returns the first three degree elements in the document:

(//degree)[position() < 4] 
               

            

The next query finds the first two book children in the current context:

book[position() <= 2] 
               

            

The XPath processor executes the position() function with respect to the parent node. Consider the following data:

<x>
               

              
<y/>
                   
<y/>
                   

                
</x> <x>
<y/>
                   
<y/>
                   

                
</x>

The following expression returns the first y element contained in each x element:

x/y[position() = 1] 
               

            

For more information, see also Finding an Element with a Particular ID.

Stylus Studio API Documentation

Java API reference materials providing detailed information about Stylus Studio and other industry leading XML processing components.

ZapForum Podcast: B2B Data Integration in a SOA World

Check out ZapThink's podcast on Business-to-Business Data Integration in a SOA World Presentation (MP3 21MB). This 1:01:17 podcast features ZapThink analysts Jason Bloomberg and Ron Schmelzer as well as expert guest Jerry King and Patrick Smith.

XML Reports

Build beautiful XML reports from Relational, XML and Legacy Data. You XML report can be rendered in PDF or HTML using XSLT, XQuery or XSL:FO.

Converting Custom EDI Message Types to XML

Vital and valuable legacy data locked in proprietary EDI files? See how to use DataDirect XML Converters™ custom EDI message type tools to convert nonconformant EDI to XML.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.