Skip to Content
XQuery
book

XQuery

by Priscilla Walmsley
March 2007
Intermediate to advanced content levelIntermediate to advanced
512 pages
21h 15m
English
O'Reilly Media, Inc.
Content preview from XQuery

xs:boolean

The primitive type xs:boolean represents a logical true or false value. The valid lexical representations for xs:boolean are false, true, 0 (which is equal to false), and 1 (which is equal to true). The values are case-sensitive, so TRUE and FALSE are not valid lexical representations.

Constructing xs:boolean Values

In addition to the standard xs:boolean constructor, xs:boolean values can be constructed using the true and false functions, which take no arguments and return the appropriate value. For example, true( ) returns the value true.

Boolean values are more often constructed indirectly, as:

  • The result of a function that returns a Boolean value, such as exists($seq1)

  • The value of a comparison expression, such as $price > 20

  • The result of a path expression that is evaluated using its effective Boolean value, such as if (doc("catalog.xml")//product) ...

In addition, a function named boolean can be used to explicitly convert a sequence to its effective Boolean value. A sequence that is an xs:boolean value false, a single number 0 or NaN, a single zero-length string, or the empty sequence, evaluates to false. Otherwise, it evaluates to true. Note that it doesn't give the same result as the xs:boolean constructor—for example, xs:boolean("false") is false, but boolean("false") is true. More information on the boolean function can be found in Appendix A.

Casting xs:boolean Values

Values of type xs:string or xs:untypedAtomic can be cast to xs:boolean. The string false (all ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XQuery, 2nd Edition

XQuery, 2nd Edition

Priscilla Walmsley
XPath and XPointer

XPath and XPointer

John Simpson
XQuery Kick Start

XQuery Kick Start

James McGovern, Per Bothner, Kurt Cagle, James Linn, Vaidyanathan Nagarajan
Learning XSLT

Learning XSLT

Michael Fitzgerald

Publisher Resources

ISBN: 0596006349Supplemental ContentErrata