• +49-(0)721-402485-12
Ihre Experten für XML, XQuery und XML-Datenbanken

FLWOR expressions

Each "meaningful" XQuery instruction is based on a FLWOR expression which represents, similar to the SELECT-FROM-WHERE in SQL, the base for queries to XML databases. The acronym FLWOR is an abbreviation of for-let-where-order by-return and is normally pronounced like the word "flower". Firstly, a general overview is given which is followed by a detailed description of the individual clauses and specifics.

Clauses of a FLWOR expression

In a FLWOR expression sequences of nodes are conceptually generated by binding variables in for and let clauses. The individual items are filtered in the following where clause regarding a preset predicate, sorted with respect to an optional order by clause and then outputted in the return clause according to the indicated element constructors, whereby the result is generated in accordance with a valid instance of the XQuery data model. The following image shows the conceptual succession of the evaluation of the clauses indicated in a FLWOR expression:

constructs of a FLWOR expression

image: Constructs of a FLWOR expression

The grammar for valid FLWOR expressions, as it is shown in extracts in the following, explains that FLWOR expressions expect in various places expressions of the XQuery query language (ExprSingle). Since FLWOR expressions in turn are XQuery expressions, valid XQuery queries may consist of complex, which means nested in one another, FLWOR expressions.

FLWORExpr::=(ForClause | LetClause)+ WhereClause? OrderByClause? return
ExprSingle
ForClause::=for $VarName TypeDeclaration? PositionalVar? in ExprSingle
(, $VarName TypeDeclaration? PositionalVar?
in ExprSingle)*
LetClause::=let $VarName TypeDeclaration? := ExprSingle
(, $VarName TypeDeclaration? := ExprSingle)*
TypeDeclaration::=as SequenceType
PositionalVar::=at $VarName
WhereClause::=where Expr
OrderByClause::=(order by | stable order by) OrderSpecList
OrderSpecList::=OrderSpec (, OrderSpec)*
OrderSpec::=ExprSingle OrderModifier
OrderModifier::=(ascending | descending)? ((empty greatest) |
(empty least))? (collation StringLiteral)?

 

 

Source: "XQuery – Grundlagen und fortgeschrittene Methoden", dpunkt-Verlag, Heidelberg (2004)

<< backnext >>