Datypic Logo
XQuery

XQuery

Priscilla Walmsley (pwalmsley@datypic.com)

ISBN: 0596006349

1st edition, 2007, O'Reilly Media, Inc.

Chapter 11: A closer look at types

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
(false(), false(), false()) Error
1, 2, 3 Error
xs:date("2007-01-15") Error
Table 11-2. Examples of generic sequence types
ExampleExplanation
node()* A sequence of one or more nodes, or the empty sequence
item()? One item (a node or an atomic value) or the empty sequence
xs:anyAtomicType+ A sequence of one or more atomic values (of any type)
Table 11-3. Examples of sequence types based on type name
ExampleExplanation
xs:integer One atomic value of type xs:integer (or any type derived by restriction from xs:integer)
xs:integer? One atomic value of type xs:integer (or any type derived by restriction from xs:integer), or the empty sequence
prod:NameType* A sequence of one or more atomic values of type prod:NameType, or the empty sequence
Table 11-4. Examples of instance of expressions
ExampleExplanation
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
ExpressionValue
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