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.

XQuery Talk Blog

Get the latest XQuery news and information at XQuery-Talk - an online community for discussing XQuery technologies, examples, implementations and more. Bookmark this RSS or ATOM feed now!

XML Applications

XML Applications are software applications that process data using standard XML technologies like XML, XML Schema, XSLT and XQuery. Using Stylus Studio XML Pipeline, learn how to model, edit, test and deploy an XML Application with ease.

Using XSLT Templates

Using XSLT Templates is an online video demonstration of the Stylus Studio XSLT designer. See just how easy it is to create, apply and match XSLT templates to your XML data to create beautiful HTML layouts for XML content publishing applications.

EXSLT Tools

EXSLT support in Stylus Studio lets you extend XSLT 1.0 stylesheets and simplify many tasks including computing dates and times, performing mathematical computations, string manipulations and more.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member