XQuery prologs and expressions
In XQuery, an XQuery expression consists of an optional prolog that is followed by an expression. The prolog contains a series of declarations that define the processing environment for the expression. The path expression consists of an expression that defines the result of the XQuery expression.
Syntax
The following diagrams show the general format of an XQuery expression.
XQuery expression >>-+--------+--expression-------------------------------------->< '-prolog-'
expression |--+-primary-expression----+------------------------------------| +-logical-expression----+ +-comparison-expression-+ +-arithmetic-expression-+ '-path-expression-------'
prolog .-----------------------------------. V | |----+-boundary-space-declaration----+-+------------------------| +-copy-namespaces-declaration---+ +-namespace-declaration---------+ '-default-namespace-declaration-'
Example
The following example illustrates the structure
of a typical expression in XQuery.
In this example, the prolog contains a namespace declaration that
binds the prefix ns1 to a URI. The expression body contains an expression
that returns all documents in the XMLPO column where the name attribute
on the shipTo node is "Jane" and the name attribute on the
billTo node is "Jason":