FLWOR
From Wikipedia, the free encyclopedia
The programming language XQuery defines FLWOR (pronounced as 'flower') as an expression that supports iteration and binding of variables to intermediate results. FLWOR is an acronym standing for FOR, LET, WHERE, ORDER BY, RETURN. FLWOR is loosely analogous to SQL's SELECT-FROM-WHERE and can be used to provide join-like functionality to XML documents.
- for creates a sequence of tuples
- let binds a sequence to a variable
- where filters the tuples on a boolean expression
- order by sorts the tuples
- return gets evaluated once for every tuple
[edit] Example
for $d in doc("depts.xml")//deptno
let $e := doc("emps.xml")//employee[deptno = $d]
where count($e) >= 10
order by avg($e/salary) descending
return
<big-dept>
{ $d,
<headcount>{count($e)}</headcount>,
<avgsal>{avg($e/salary)}</avgsal>
}
</big-dept>

