MarkLogic 9 Product Documentation
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)
Powered by MarkLogic Server | Terms of Use | Privacy Policy