Determining the Context Size

To obtain the number of nodes in the current context, call the last() function. The format is

number last() 
               

            

The last() function returns a number equal to the context size of the expression evaluation context. Essentially, the last() function returns the position number of the last node in document order for the current context. For example, the following query returns all books if there are three or more of them. There are three book elements in the current context. Consequently, this query returns three book elements.

/bookstore/book[last() >= 3]
               

            

 
Free Stylus Studio XML Training:
W3C Member