Expressions

This document describes the expressions available in X-Query. The names of the expressions correspond to the language constructs of X-Query. In many cases, these are equivalent to an XPath expression of the same name. However, in a few cases the meaning is different or the expression only exists in X-Query, since its serves a special purpose in the context of a database. A syntax diagram illustrates the definition as it appears in the respective production rule of the X-Query grammar. The description is followed by an XPath compatibility note and one or more examples.

The most basic parts of the X-Query language are not covered; we summarize them here. Digits, numbers, and operators are defined as in the lexical rules of the XPath specification (in Section 3.7). However, X-Query adds to the list of operators the special contains operator ~=, which provides text retrieval capabilities. The list of operator names (OperatorName, defined in XPath, Section 3.7, Rule 33) is extended by adj, after, before, betw, between, near, intersect. All of these additions are described below.

The following table lists the expressions available in X-Query, along with the corresponding XPath expressions. An asterisk (*) after the name of an XPath expression indicates that this expression is implemented differently in X-Query. The link in the XPath column leads you to the expression's production rule in the XPath specification.

X-Query Expression XPath Expression Short Description
AbbrevAbsoluteLocPath AbbreviatedAbsoluteLocationPath select all nodes satisfying some condition
AbbreviatedAxisSpecifier AbbreviatedAxisSpecifier specify either child or attribute axis
AbbreviatedStep AbbreviatedStep select context node or its parent node
AbsoluteLocationPath AbsoluteLocationPath location path starting at the root node
AdditiveExpr AdditiveExpr add or subtract numeric values
AndExpr AndExpr check if two or more conditions are all true
Argument Argument input to a FunctionCall
AxisName AxisName * specify axis by name
AxisSpecifier AxisSpecifier specify axis in a location step
BetweenExpr select nodes based on a value range
EqualityExpr EqualityExpr * check if two values are equal
Expr Expr general X-Query expression
FilterExpr FilterExpr * select a subset of nodes satisfying some condition
FunctionCall FunctionCall call to a function
LocationPath LocationPath select nodes along a path
MultiplicativeExpr MultiplicativeExpr perform multiplication, division and modulo operations
NameTest NameTest check for name of specified node
NodeTest NodeTest * check for type or name of specified node
NodeType NodeType * token representing a type of node
OrExpr OrExpr check if one of the given conditions is true
PathExpr PathExpr select a set of nodes
Predicate Predicate select a subset of nodes for which the predicate is true
PredicateExpr PredicateExpr expression used in a predicate
PrimaryExpr PrimaryExpr expression without operators
ProximityExpr specify adjacent values
RelationalExpr RelationalExpr compare two numeric values
RelativeLocationPath RelativeLocationPath select nodes relative to the context node
SequenceExpr select nodes based on sibling positioning
SetExpr UnionExpr * select union or intersection of node sets
SortByClause sort a node set
SortByCharacteristics determine sorting order
Step Step select a subset of nodes on a given axis
UnaryExpr UnaryExpr change number sign