FLWOR

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

FLWOR (pronounced 'flower') is an expression in the XQuery programming language that supports iteration and binding of variables to intermediate results. FLWOR is an acronym 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 nodes *let binds a sequence to a variable *where filters the nodes on a boolean expression *order by sorts the nodes *return gets evaluated once for every node

FLWOR (pronounced 'flower') is an expression in the XQuery programming language that supports iteration and binding of variables to intermediate results. FLWOR is an acronym 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 nodes let binds a sequence to a variable where filters the nodes on a boolean expression order by sorts the nodes return gets evaluated once for every node

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 { $d, {count($e)} , {avg($e/salary)} } First column of the XQuery request shows the for, let, where, order by and return keywords of the FLWOR paradigm. In plain English, this could be read as "Get all departments that have more than ten employees, order these departments by decreasing average salary, and return a report of department numbers, head counts and average salary in each big department". The result could look like: 17 25 12500 24 18 11327 3 32 10725

Example using Microsoft SQL Server

DECLARE @xml XML SET @xml = ' 42 27 a b ' SELECT x.y.query('for $s in self::node() return $s//item_1/text()') as i, x.y.query('for $s in self::node() return $s//item_2/text()') as j FROM @xml.nodes('/root_element') AS x(y);

References

Text derived from https://en.wikipedia.org/w/index.php?oldid=1318807495 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

1 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.