XPath prologs and expressions
In DB2® XPath, an XPath 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 expression consists of an expression that defines the result of the XPath expression.
Syntax
The following diagrams show the general format of an XPath expression.
XPath expression >>-+--------+--expression-------------------------------------->< '-prolog-'
expression |--+-primary-expression----+------------------------------------| +-logical-expression----+ +-comparison-expression-+ +-arithmetic-expression-+ '-path-expression-------'
prolog .-----------------------------------. V | |----+-namespace-declaration---------+-+------------------------| '-default-namespace-declaration-'
Example
The
following example illustrates the structure of a typical expression
in DB2 XPath. In this example,
the prolog contains a namespace declaration that binds the prefix ipo to
a URI. The expression body contains an expression that returns one
row for each ipo:purchaseOrder element with
XML documents stored in the XMLPO column. A predicate is used to specify
that 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 DB2 XPath
SELECT X.* FROM T1, XMLTABLE ('declare namespace ipo="http://www.example.com/IPO";
/ipo:purchaseOrder[shipTo/@name = "Jane" and billTo/@name = "Jason"]'
PASSING T1.XMLPO) X;