Finding Nodes Relative to the Last Node in a Set

To obtain nodes relative to the last node in the set, use the position() and last() functions with arithmetic. For example, the following queries both obtain the last author element in the current context:

author [position() = last()]
               
author [last()]
               

            

The following queries both return the next-to-last author element:

author [position() = last() - 1]
               
author [last() - 1]
               

            

For information about position(), see Determining the Position Number of a Node. For information about last(), see Determining the Context Size.

Building DataDirect XQuery Applications

Stylus Studio further simplifies relational and XML data integration by providing advanced XQuery tools support for building XQuery applications which use DataDirect XQuery.

Consumer Food Products

Want to know what special ingredient is in these consumer food product companies work enviornment? Well it's a touch Stylus Studio that give these consumer food product companies the extra edge they need for producing such high quality food products!

XML Processing

Learn how to simplify XML Processing using Stylus Studio XML Pipeline, the easiest way to visually design and deploy virtually any XML processing tasks.

Learn XSLT and XQuery Profiling

Stylus Studio's Profiler can help you evaluate the performance of your XQuery and XSLT. Automatically generated, customizable, easy-to-read HTML reports provide insight into performance bottlenecks.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member