Loading TOC...

fn:zero-or-one

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

Summary

Returns $arg if it contains zero or one items. Otherwise, raises an error [err:FORG0003].

For detailed type semantics, see Section 7.2.16 The fn:zero-or-one, fn:one-or-more, and fn:exactly-one functions[FS].

Parameters
arg The sequence of items.

Example

fn:zero-or-one("hello")

=> "hello"

fn:zero-or-one(("hello", "goodbye"))

=> XDMP-MORETHANONEITEM exception (because there are two items)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.