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
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":Figure 1. Structure
of a typical expression in XQuery
SELECT XMLQUERY ('declare namespace ipo="http://www.example.com/IPO";
/ipo:purchaseOrder[shipTo/name = "Jane" and
billTo/name = "Jason"]'
PASSING XMLPO)
FROM T1;