Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Note that the effective boolean value of a sequence doesn't simply test whether the sequence is empty, because of the special cases for a singleton sequence. If you want to test whether a sequence is empty, use the
empty()
or
exists()
functions described in Chapter 13.
These rules for forming the effective boolean value are consistent with the rules used in other XPath contexts where a true/false value is required. These include:
The same rules are also used in XSLT 2.0, in evaluating the
A significant feature of these rules is that the processor can determine the effective boolean value of any sequence without looking further than the second item in the sequence. This makes the algorithm very efficient.
However, the rules are not the same as the rules in XML Schema for converting a string to an
xs:boolean
value. In XML Schema, the valid lexical representations of the
xs:boolean
value
false
are
0
and
false
, while the valid lexical representations of
true
are
1
and
true
. The XML Schema rules are used in XPath 2.0 in the following circumstances: