fn:boolean( $arg as item()*, [$collation as xs:string] ) as xs:boolean
Computes the effective boolean value of the sequence $arg. See Section 2.4.3 Effective Boolean Value[XP].
Parameters | |
---|---|
$arg | A sequence of items. |
collation | The optional name of a valid collation URI. For information on the collation URI syntax, see the Search Developer's Guide. |
When using XQuery version "1.0-ml", this function implements the semantics from May 2003.
If $arg
is the empty sequence, fn:boolean returns false.
If $arg
is a sequence whose first item is a node, fn:boolean returns true.
If $arg
is a singleton value of type xs:boolean or a derived from xs:boolean,
fn:boolean returns $arg
.
If $arg
is a singleton value of type xs:string or a type derived from xs:string
or xs:untypedAtomic, fn:boolean returns false if the operand value has zero
length; otherwise it returns true.
If $arg
is a singleton value of any numeric type or a type derived from a
numeric type, fn:boolean returns false if the operand value is NaN or is
numerically equal to zero; otherwise it returns true.
In all other cases, fn:boolean raises a type error [err:FORG0006] when run in XQuery strict mode (1.0).
The static semantics of this function are described in Section 7.2.4 The fn:boolean function[FS].
Note:
The result of this function is not necessarily the same as " $arg cast as xs:boolean ". For example, fn:boolean("false") returns the value "true" whereas "false" cast as xs:boolean returns false.
xquery version "1.0"; let $x := ("a", "b", "c") return fn:boolean($x) => raises a type error [err:FORG0006]. xquery version "1.0-ml"; let $x := ("a", "b", "c") return fn:boolean($x) => true let $x := ("a", "b", "c") return fn:boolean($x[1]) => returns true. let $x := ("a", "b", "c") return fn:boolean($x[0]) => returns false.