home contribute faq download

FunctX XSLT Functions

fn:zero-or-one

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

Google
Webxsltfunctions.com

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.

This description is © Copyright 2007, O'Reilly Media. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameType
$arg item()*
return value item()?

Examples

XSLT ExampleResults
zero-or-one( () )
()
zero-or-one('a')
a
zero-or-one( ('a', 'b') )
Error FORG0003

See Also

fn:one-or-moreReturns a sequence if it contains one or more items, otherwise errors
fn:exactly-oneReturns a sequence if it contains exactly one item, otherwise errors

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley