FLWOR

From Wikipedia, the free encyclopedia

The programming language XQuery defines FLWOR or FLWR (often pronouced as 'flower') as 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 provides join-like functionality to XML documents.

  • for and let create a sequence of tuples
  • where filters the tuples on a boolean expression
  • order by sorts the tuples, using any comparable data
  • return gets evaluated once for every tuple (think do)

[edit] Example

For example

 for $d in document("depts.xml")//deptno
   let $e := document("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>

[edit] External links