zero-or-one

Returns a sequence if it contains zero or one items, otherwise errors

Description

The fn:zero-or-one function returns $arg if it contains zero or one items. Otherwise, the error FORG0003 is raised. This function is useful when static typing is in effect, to avoid apparent static type errors.

Parameters

Description

arg:item()

Examples

XPath

Results

zero-or-one( () )

()

zero-or-one(‘a’)

a

zero-or-one( (‘a’, ‘b’) )

Error FORG0003

See Also