XQuery

XQuery

(pwalmsley@datypic.com)

ISBN: 1491915103

2nd edition, , O'Reilly Media, Inc.

Chapter 11: A Closer Look at Types

Please note that the book contains many inline examples and informal tables that are not provided here.

Table 11-1. Examples of effective boolean value
ExampleEffective boolean value
() false
false() false
true() true
"" false
"false" true
"x" true
0 false
xs:float("NaN") false
(false() or false()) false
doc("prices.xml")/* true
<a>false</a> true
<a>{xs:boolean("false")}</a> true
(false(), false(), false()) Error FORG0006
1, 2, 3 Error FORG0006
xs:date("2015-01-15") Error FORG0006
[true()] Error FORG0006
data( [true()] ) true
Table 11-4. Examples of instance of expressions
ExampleReturn value
3 instance of xs:integer true
3 instance of xs:decimal true, because xs:integer is derived by restriction from xs:decimal
<x>{3}</x> instance of xs:integer false, because the element node x is untyped, even though it happens to contain an integer
<x>{3}</x> instance of element() true
<x>{3}</x> instance of node() true
<x>{3}</x> instance of item() true
(3, 4, 5) instance of xs:integer false
(3, 4, 5) instance of xs:integer* true
xs:float(3) instance of xs:double false
Table 11-5. Examples of casting to xs:string and xs:untypedAtomic
ExampleReturn value
xs:string("012") "012"
xs:string(012) "12"
xs:string(xs:float(12.3E2)) "1230"
xs:untypedAtomic(xs:float(12)) 12 (of type xs:untypedAtomic)
xs:string(true()) "true"
Datypic XQuery Services