last
The size of the current context
Description
The fn:last function returns an integer representing the number of items in the current context. It is most often used in the predicate of path expressions, to retrieve the last item. For example, catalog/product[fn:last()] returns the last product child of catalog. That is because the fn:last function returns 4, which serves as a positional predicate to retrieve the 4th product. The fn:last function is also useful for testing whether an item is the last one in the sequence.
Examples
XPath |
Results |
---|---|
doc(’http://www.functx.com/input/catalog.xml’)/catalog/product[last()] |
the last product child of catalog |