fn:last

Return number of items in the current sequence.

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:


Syntax

fn:last => unsignedInt?

Description

This context function returns the number of items in the sequence of items that is currently being processed. The function returns the empty sequence if the context is the empty sequence.

Example

  • Retrieve the current German chancellor:

    let $chancellors := ("Adenauer", "Erhard", "Kiesinger", "Brandt", "Schmidt", "Kohl", "Schröder", "Merkel")
    return
    <info>Current German chancellor is: { $chancellors[last()] }.</info>

    The query returns that string value from $chancellors sequence which is the last sequence item.