Effective Boolean value

The effective Boolean value (EBV) of a sequence is computed implicitly during the processing of expressions that require Boolean values. The EBV of a value is determined by applying the fn:boolean function to a value.

The following table describes the EBVs that are returned for specific types of values.
Table 1. EBVs returned for specific types of values in XQuery
Description of value EBV returned
An empty sequence false
A sequence whose first item is a node true
A single value of type xs:boolean (or derived from xs:boolean) false - if the xs:boolean value is false
true - if the xs:boolean value is true
A single value of type xs:string or xdt:untypedAtomic (or derived from one of these types) false - if the length of the value is zero
true - if the length if the value is greater than zero
A single value of any numeric type (or derived from a numeric type) false - if the value is NaN or is numerically equal to zero
true - if the value is not numerically equal to zero
All other values error
Note: The effective Boolean value of a sequence that contains at least one node and at least one atomic value is nondeterministic in a query where the order is unpredictable.
The effective Boolean value of a sequence is computed implicitly when the following types of expressions are processed:
  • Logical expressions (and, or)
  • The fn:not function
  • The where clause of a FLWOR expression
  • Certain types of predicates, such as a[b]
  • Conditional expressions (if)
  • Quantified expressions (some, every)