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.
This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book. Arguments and Return TypeName | Type |
return value |
xs:integer |
ExamplesXPath Example | Results |
---|
doc(
'https://www.datypic.com/functx./input/catalog.xml')/
catalog/product[last()] |
the last product child of catalog |
See AlsoHistory |
Recommended Reading:
|