XPath/XQuery zero-or-one function

Summary

Returns $arg if it contains zero or one items. Otherwise, raises an error.

Signature

fn:zero-or-one(
$arg as item()*
) as item()?

Properties

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

Rules

Except in error cases, the function returns $arg unchanged.

Error Conditions

A dynamic error is raised if $arg contains more than one item.