XPath/XQuery head function

Summary

Returns the first item in a sequence.

Signature

fn:head(
$arg as item()*
) as item()?

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

The function returns the value of the expression $arg[1]

Examples

The expression fn:head(1 to 5) returns 1.

The expression fn:head(("a", "b", "c")) returns "a".

The expression fn:head(()) returns ().

The expression fn:head([1,2,3]) returns [1,2,3].

Notes

If $arg is the empty sequence, the empty sequence is returned. Otherwise the first item in the sequence is returned.