zero-or-one function
The fn:zero-or-one function returns its argument if the argument contains one item or is the empty sequence.
Syntax
- sequence-expression
- Any sequence, including the empty sequence.
Returned value
If sequence-expression contains one item or is the empty sequence, sequence-expression is returned. Otherwise, an error is returned.
Example
The following example uses the fn:zero-or-one function to determine if the sequence in variable $seq contains one or fewer items.
let $seq := (5,10)
return fn:zero-or-one($seq)
An error is returned because the sequence contains two items.