home contribute faq download

FunctX XSLT Functions

fn:last

The size of the current context

Google
Webxsltfunctions.com

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 Type

NameType
return value xs:integer

Examples

XSLT ExampleResults
<doc(
   'http://www.functx.com/input/catalog.xml'>/
   catalog/product[last()]
the last product child of catalog

See Also

functx:last-nodeThe XML node in a sequence that is last in document order
fn:positionThe current context position

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery