Specifying the XQuery Version
DataDirect XQuery supports both XQuery 1.0 and XQuery 1.1. You can use a version declaration to indicate whether you want your XQuery code processed using DataDirect’s XQuery 1.0 or XQuery 1.1 processing engine. Unless a version is specified explicitly, XQuery code is processed using the XQuery 1.1 processing engine.
Where to Specify Version
You can specify the XQuery version in two places:
- In the main query, using query prolog. Setting the XQuery version in the query prolog affects processing for the entire query, unless a different version has been set for an individual module.
- In one or more modules. Each module can have its own version setting. A module retains its version setting when it is imported.
When to Specify Version
Generally speaking, there is no need to specify the XQuery version because XQuery 1.1 is backwards-compatible with XQuery 1.0.
However, if you write modules that use XQuery 1.1 functionality – to use FLWOR expressions for grouping, for example – consider specifying the version explicitly within that module. Knowing the XQuery version associated with a module can be useful to others who import modules into their XQuery code.
If DataDirect XQuery encounters a module with an XQuery 1.0 declaration in the context of a main module whose version is declared (explicitly or not) as 1.1, DataDirect XQuery uses its XQuery 1.0 processor for that module and then reverts to using the 1.1 XQuery processor for the remainder of the query.
How to Specify Version
The syntax for the version declaration is: