XQuantum Alignment with XQuery 1.0
XQuantum fully supports the XQuery 1.0 standard and a subset of the May 1, 2006 Full-Text draft standard.
The optional XQuery features for Static Typing and Modules are also fully supported.
The XQuantum type system generalizes the sequence type syntax of the XQuery standard to include full regular expression types.
We refer to this extended type system as the regular type system.
The rationale for using regular types is discussed below under the heading Regular Type System.
Features in XQuantum 1.0
Static Type Checking
Effective Boolean Value
Ordered and Unordered Expressions
NaN, INF, -INF Values
Additional Features in XQuantum 1.50
Processing Instruction Nodes
Default Collation Declaration
General Type Constructors
Base URI Declaration
Ordering Mode Declaration
Empty Order Declaration
Unicode Character Encodings
XML Schema Datatypes
Dates, Times, and Durations
Built-in Functions and Operators
Regular Expression Types
Regular Type Declarations
Regular Type Modules
Validation with Regular Types
Enclosed Expression Typing
Advanced Whitespace Options
Regular Type System
XQuantum generalizes the XQuery sequence type syntax by adding a choice type operator, | and a sequence type operator, comma.
With these extensions, you can specify types which allow arbitrary combinations of elements with different content models.
XQuantum also allows you to declare type definitions in the query prolog, and
you can optionally type external XML files using regular type definitions stored in .rtd files.
The goal of making these changes is to give XQuery a type system that is integrated into the language as is typically the case with other programming languages.
The XQuery standard provides a limited type system internal to the language and requires that you specify complex types externally using XML Schema, a different language.
The following query example illustrates some of the features just described. It declares a BOOK type and uses it to validate an untyped XML value, producing a typed value.
During validation against the BOOK type, the year attribute is converted into an xs:integer, and all the element values are converted into xs:strings.
declare type BOOK := element(book, (
declare variable $book :=
<title>The XML Companion</title>
$book validate as BOOK
Regular types differ semantically from sequence types, in that regular types use structural typing as opposed to named typing.
This means that regular types are compared based on their structure. Two types with the same structure are the same, even if they have different names.
Regular Type Grammar
The grammar used for regular types is the same that is used for sequence types in the standard,
except that a choice operator, '|', and a sequence operator, ',' have been added.
Parenthesis should be used around choice and sequence types whenever they are used in type declarations or passed as arguments to type constructors,
choice | sequence
The builtin grammar symbol represents one of the built-in types defined above, and the name symbol represents a user-defined type name.
The grammar gives the sequence operator higher precedence than the choice operator.