Computes the effective boolean value of the sequence $arg
.
fn:boolean
( $arg
as item()*
xs:boolean
The function computes the effective boolean value of a sequence, defined according to the following rules. See also .
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
, xs:anyURI
or a type derived from
xs:anyURI
, 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
.
let $abc := ("a", "b", "")
fn:boolean($abc)
raises a type error .
The expression fn:boolean($abc[1])
returns true()
.
The expression fn:boolean($abc[0])
returns false()
.
The expression fn:boolean($abc[3])
returns false()
.
fn:boolean([])
raises a type error .
In all cases other than those listed above, fn:boolean
raises a type error .
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
(which can also be
written xs:boolean("false")
) returns false
.