Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
397
XQuery FLWR Expressions
FLWR Expressions are pronounced as "flower expressions". This is
one of the most powerful expression types of XQuery. It allows for writing
xqueries in a SQL-like style, and can be fully nested. It also allows for
processing xqueries very efficiently. FLWR expressions allow for the use of
other kinds of expressions, like constructors, conditional, and logical
expressions, and more.
NOTE: currently, an ORDER BY clause has been added, so the name has changed
to FLWOR, while the pronunciation stays the same. However, MS XQuery Demo is not
yet based on the current specs, so this change will be incorporated by me in a
future update when the demo is updated.
This xquery is exactly the same as the second example in the Path
Expression example section above. This time however, we can use the FLWR
Expression type to create very powerful xqueries. Let's look at a second
example to see how.
A common way to nest FLWR Expressions is to include a new FLWR
expression after the RETURN keyword; an example that builds on the
previous example is as follows:
2. <root>
{
FOR $a IN document("xqt")//tutorials
RETURN
<tutorial>
{
FOR $b IN document("xqt")//tutorials
WHERE $a = $b
RETURN $b/tutorial/id
}
</tutorial>
}
</root>
Although we do not have a second document (navigator) available (only
"xqt" is present in the navigator collection), this xquery shows
how we could produce a UNION of two or more different tables, using XQuery.
The xquery produces the following output: