Literals and Operators

Now that we know about values and types in XQuery, we describe how the static type system assigns types to expressions. The static type system checks that the type of an expression is compatible with the type required by the context in which the expression is used. If they are not compatible, the static type system raises a type error.

In the remaining sections, the term type refers to the static type associated with an XQuery expression. We use the phrase dynamic type whenever referring to the type associated with a value.

Literals are the simplest XQuery expressions. Every literal expression has one of the types xs:string, xs:integer, xs:decimal, or xs:double. Here are some examples:

"hello" has type xs:string
42 has ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.