Performing a FLWOR expression is the main use case for XQuery. It stands for:
for
let
where
order by
return
Which are the keywords XQuery uses to achieve it’s queries.
Syntax
books.xml
Link to original <bookstore> <book> <name>All about XML</name> <price>$20</price> </book> <book> <name>Learning XQuery</name> <price>$15</price> </book> </bookstore>
for $x in doc("books.xml")/bookstore/book
where $x/price<20
order by $x/title
return $x/title
This FLWOR expression reads all the title
s of book
s with price
under $, sorted by the title
s.