3 Expressions


This section describes how DataDirect XQuery supports the following XQuery expressions.

Primary Expressions

Table A-7 describes how DataDirect XQuery supports XQuery primary expressions.

Table A-7. XQuery Primary Expressions 
XQuery Language
Support
Literals)
Supported.
For relational sources, the default encoding for string literals is the encoding used by the database. You can set it to Unicode using the option declaration sql-unicode-literals.
By default, the precision and scale for decimals is:
DB2: 30, 15
Informix: 32, 15
Oracle: No default
PostgreSQL: No default
Microsoft SQL Server: 38,19
Sybase: 38, 19
You can override the database default by using the sql-decimal-cast option declaration. See Option Declarations for details. Also, the following constructor function creates a decimal that allows you to set the precision and scale:
ddtek:decimal ($arg as xs:anyAtomicType?, 
$precision as xs:integer, $scale as xs:integer) 
as xs:decimal? 
Variable references
Supported.
Parenthesized expressions
Supported.
Context item expression
Supported, except for initial context item.
Function calls
Supported.

Path Expressions

Table A-8 describes how DataDirect XQuery supports path expressions.

Table A-8. XQuery Path Expressions 
XQuery Language
Support
Steps
  
 
Axis
Supported, except for the Full Axis feature.
 
Nodes tests
Supported.
For relational sources, name tests and kind tests that specify a name are not supported when the test is applied to a node with a computed name. In such cases, an error is raised. For example, the following XQuery raises an error:
for $h in collection(’holdings')/holdings/* 
return 
   document { 
      element {name($h)} {string($h)} 
   } / stockholder 
Predicates
Supported. Numeric predicates are compensated for relational sources. See Understanding Compensation.
Unabbreviated syntax
Supported.
Abbreviated syntax
Supported.

Sequence Expressions

Table A-9 describes how DataDirect XQuery supports sequence expressions.

Table A-9. XQuery Sequence Expressions 
XQuery Language
Support
Constructing sequences
Supported. Range expressions are compensated for relational sources. See Understanding Compensation.
Filter expressions
Supported. Numeric predicates in filter expressions are compensated for relational sources. Understanding Compensation.
Combining node sequences
Supported.

Arithmetic Expressions

Table A-10 describes how DataDirect XQuery supports arithmetic expressions.

Table A-10. XQuery Arithmetic Expressions 
XQuery Language
Support
Arithmetic expressions
Supported. For relational sources, see Functions and Operators for restrictions.

Comparison Expressions

Table A-11 describes how DataDirect XQuery supports comparison expressions.

Table A-11. XQuery Comparison Expressions 
XQuery Language
Support
Value comparisons
Supported.
General comparisons
Supported.
Node comparisons
Supported.

Logical Expressions

Table A-12 describes how DataDirect XQuery supports logical expressions.

Table A-12. XQuery Logical Expressions 
XQuery Language
Support
Logical expressions
Supported.

Constructors

Table A-13 describes how DataDirect XQuery supports constructors.

Table A-13. XQuery Constructors 
XQuery Language
Support
Direct element constructors
Supported.
 
Attributes
Supported.
 
Namespace declaration attributes
Supported.
 
Content
Supported.
 
Boundary whitespace
Supported.
Other direct constructors
Supported.
 
Computed element constructors
Supported.
 
Computed attribute constructors
Supported.
 
Document node constructors
Supported.
 
Text node constructors
Supported.
 
Computed processing instruction constructors
Supported.
 
Computed comment constructors
Supported.
In-scope namespaces of a constructed element
Supported. DataDirect XQuery only supports inherit and preserve for the copy-namespaces mode.

FLWOR Expressions

Table A-14 describes how DataDirect XQuery supports FLWOR expressions.

Table A-14. XQuery FLWOR Expressions 
XQuery Language
Support
FLWOR expressions
Supported. For relational sources, positional variables are compensated. Also, relational sources do not support the collation in order by clauses. Any specified collation is ignored and sorting is performed according to the collation used by the database.
See Specifying Collations for more information about using the collation parameter. See Restructuring Data: FLWOR Expressions for more information on using FLWOR expressions in your XQuery.

Ordered and Unordered Expressions

Table A-15 describes how DataDirect XQuery supports ordered and unordered expressions.

Table A-15. XQuery Ordered and Unordered Expressions 
XQuery Language
Support
Ordered expressions
Supported.
Unordered expressions
Supported.

Conditional Expressions

Table A-16 describes how DataDirect XQuery supports conditional expressions.

Table A-16. XQuery Conditional Expressions 
XQuery Language
Support
Conditional expressions
Supported.

Quantified Expressions

Table A-17 describes how DataDirect XQuery supports quantified expressions.

Table A-17. XQuery Quantified Expressions 
XQuery Language
Support
Quantified expressions
Supported.

Expressions on SequenceTypes

Table A-18 describes how DataDirect XQuery supports expressions on SequenceTypes.

Table A-18. XQuery Expressions on Sequence Types 
XQuery Language
Support
Instance of
Supported. Compensated for relational sources. See Understanding Compensation.
Typeswitch
Supported. Compensated for relational sources. See Understanding Compensation.
Cast
For relational sources, not all data types are supported. See Data Type Mappings for tables of supported database data types and information about how they are mapped to the XML schema data types. If the XML schema data type specified in a cast expression is not supported, the cast expression is compensated. See Understanding Compensation.
Castable
Supported. Compensated for relational sources. See Understanding Compensation.
Constructor functions
Supported.
For relational sources, not all constructor functions are supported. See 5 Constructor Functions for which types are supported. If an XQuery expression specifies a constructor function that is not supported, the constructor function is compensated. See Understanding Compensation.
Treat
Supported. Compensated for relational sources. See Understanding Compensation.

Validate Expressions

Table A-19 describes how DataDirect XQuery supports validate expressions.

Table A-19. XQuery Validate Expressions 
XQuery Language
Support
Validate expressions
Not supported.
NOTE: DataDirect XQuery supports a built-in validate function, ddtek:validate. See ddtek:validate.

Extension Expressions

Table A-20 describes how DataDirect XQuery supports extension expressions.

Table A-20. XQuery Extension Expressions 
XQuery Language
Support
Extension expressions
Supported. See Using Extension Expressions for details.