Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
An XQuery can be as simple as a single XPath expression or as complicated as a query with functional calls, conditional processes, and XML result constructions. In general, XQuery syntax is a FLWOR (pronounced “flower”) expression. FLWOR stands for for, let, where, order by, and return:
For Iterates over a sequence of items, each of which could be XML nodes or atomic values.
Let Declares variables that can be sequences of XML nodes or atomic values.
Where Defines the conditions for filtering the result.
Order By Specifies the sorting order of the result.
Return Returns the result content.
The following is a typical XQuery example with a FLWOR expression (xq_flwor.sql):
Listing 8-1 XQuery FLWOR Expression in XMLQuery()