fn.boolean( $arg as ValueIterator | Array, [$collation as String] ) as Boolean
Computes the effective boolean value of the sequence $arg. See Section 2.4.3 Effective Boolean Value[XP].
NOTE: NEW 1.0 SEMANTICS NOT IMPLEMENTED: STILL USES MAY 2003 SEMANTICS.
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.
var x = ["a", "b", "c"]; fn.boolean(x); => true var x = ["a", "b", "c"]; fn.boolean(x[0]); => true var x = ["a", "b", "c"]; fn.boolean(x[4]); => false
Comments