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 Functions - User Defined Functions in XQuery

Dr. Michael Kay's tutorial entitled: 'Defining your own Functions in XQuery' explains how to write powerful User Defined Functions in XQuery.

Publishing & Printing

It is really hard to get things to look pretty, especially XML. That's why these publishing & printing companies use Stylus Studio to make a Mona Lisa out of data integration. Check out these top companies that are "stunning" with Stylus Studio!

Multi Channel Publishing

Multi channel publishing lets you go beyond single-source publishing of HTML and PDF to also generate simultaneously for non-document forms, such as to communicate with partners or drive spreadsheets.

Learn SQL/XML

Learn how to access and update relational databases using industry-standard SQL/XML technologies along with Stylus Studio's DB-to-XML editor and File Explorer technologies.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member