Home   |   Products   |   Purchase   |   Support   |   XQuery Demo   |   About Us   |   Contact Us  
» XQuery Demo
» Use Cases
» Simple Queries
» Type Examples
» Full-text Search
» About XQuantum
» Alignment


 

XQuantum Alignment with XQuery 1.0

This document compares the current version of XQuantum with the April 4, 2005 draft of XQuery 1.0: An XML Query Language and the April 4, 2005 draft of XQuery 1.0 and XPath 2.0 Full-Text

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 Supported

Static Type Checking
Document Order
Atomization
Effective Boolean Value
SequenceType Syntax
SequenceType Matching
Variable References
Function Calls
Path Expressions
Sequence Expressions
Arithmetic Expressions
Value Comparisons
General Comparisons
Node Comparisons
Logical Expressions
Direct Constructors
Computed Constructors

FLWOR Expressions
Ordered and Unordered Expressions
Conditional Expressions
Quantified Expressions
Instance Of
Typeswitch
Cast
Castable
Treat
Version Declaration
Module Declaration
Module Import
Variable Declaration
Function Declaration
Full-text Operators
NaN, INF, -INF Values
ISO-8859-1 Encoding

Language Extensions

Regular Expression Types
Regular Type Declarations
Regular Type Modules

Validation Using Regular Types
Generalized Cast Operator
Enclosed Expression Typing

Features Not Supported

Predefined Schema Types
Processing Instruction Nodes
Comment Nodes
Namespace Awareness
Extension Expressions
Boundary-space Declaration
Default Collation Declaration
General Type Constructors
Collation Sequences
Position Variables

Base URI Declaration
Construction Declaration
Ordering Mode Declaration
Empty Order Declaration
Copy-Namespaces Declaration
Schema Import
Option Declaration
Full-text Proximity Operators
Non ISO-8859-1 Encodings

Built-in Types
The following built-in data types are supported by XQuantum and may be used to construct complex types. The combining operators for types are, | * + ? element, and attribute.

void()
item()
node()

text()
xs:untypedAtomic
xs:anyAtomicType

xs:anyType xs:boolean
xs:decimal

xs:double
xs:integer
xs:string

Key Words
The following key words and phrases are implemented in the current implementation of XQuantum:

all
and
any
as
ascending
assert
atom
attribute
boolean
by
case
cast
castable
child
count
declare
default
descendant
descendant-or-self
descending
div
doc
document
document-node

element
else
empty
encoding
eq
every
except
false
follows
for
ftcontains
function
ge
gt
highlight
idiv
if
import
in
instance
intersect
is
item
last

le
let
lt
mod
module
namespace
ne
node
none
not
of
or
order
ordered
parent
position
precedes
return
satisfies
score
self
some
stemming
subtype

text
then
to
treat
true
type
typeswitch
union
unordered
validatable
validate
value
variable
version
void
where
with
without
word
words
xquery

Operators
The following operators, (listed in order of increasing precedence), are implemented in XQuantum:

,
:=
or
and
<
>
<=
>=
=
!=
lt
gt
le

ge
eq
ne
<<
>>
is
precedes
follows
ftcontains
highlight
||
&&
to

+
-
*
div
idiv
mod
union
|
intercept
except
instance of
treat as
cast as

validate as
castable
validatable
+
-
+
*
/
//
( )
[ ]
{ }

Built-in Functions
The following built-in functions are implemented or partially implemented:

fn:node-name
fn:string
fn:data
fn:error
xs:boolean
xs:integer
xs:decimal
xs:double
xs:string
fn:abs
fn:ceiling
fn:floor
fn:round
fn:compare
fn:concat
fn:string-join

fn:substring
fn:string-length
fn:normalize-space
fn:upper-case
fn:lower-case
fn:translate
fn:escape-uri
fn:contains
fn:starts-with
fn:ends-with
fn:substring-before
fn:substring-after
fn:matches
fn:replace
fn:tokenize
fn:true

fn:false
fn:not
fn:name
fn:number
fn:local-name
fn:root
fn:boolean
fn:index-of
fn:empty
fn:exists
fn:distinct-values
fn:insert-before
fn:remove
fn:reverse
fn:subsequence
fn:zero-or-one

fn:one-or-more
fn:exactly-one
fn:deep-equal
fn:count
fn:avg
fn:max
fn:min
fn:sum
fn:doc
fn:doc-available
fn:position
fn:last
fn:date
fn:distinct-nodes
fn:decimal-format

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.

    declare type BOOK := element(book, (
        attribute(year, xs:integer),
        element(title, xs:string),
        element(author, xs:string)+)
    );

    declare variable $book :=
    <book year="1999">
        <title>The XML Companion</title>
        <author>Neil Bradley</author>
    </book>;

    $book validate as BOOK
    
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.

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,

type

choice


sequence


repeat




primary








→ 

→ 





→ 




→ 








choice

choice | sequence
sequence

sequence, repeat
repeat

repeat *
repeat +
repeat ?
primary

document-node( )
document-node(repeat)
element( )
element(name)
element(name, repeat)
attribute( )
attribute(name)
attribute(name, repeat)
(choice)
builtin
name

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.



Copyright © 2007 Cognetic Systems, Inc. | Legal Notices | Privacy Statement