BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
XQuery
XQuery Constructors
XQuery Logical Expressions
XQuery Comparison Expressions
XQuery Arithmetic Expressions
XQuery Sequence Expressions
Path Expressions
XQuery Primary Expressions
Programming with XQuery classes
XQuery Demo namespace
XQuery Demo
What is XQuery and ASP.NET?
What is XQuery?
Why do I need XQuery when I already have XSLT/XPath?
XQuery 1.0 syntax types and some query examples.
How to use XQuery in ASP.NET
Learn XQuery 1.0 fundamentals
<< XmlSerializer
XSLT >>

By :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.

Worksheet 7: FLWR Expression examples

Expression:

Example(s):

FLWR Expressions

1. <root>

   {

     FOR $a IN document("xqt")//tutorials

     RETURN $a/tutorial/title

   }

   </root>

This xquery returns the following:

<?xml version="1.0"?>

<root>

  <title>Introduction to XQuery</title>

  <title>XQuery's Syntax</title>

  <title>XQuery: Advanced Tricks</title>

</root>

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:

<?xml version="1.0"?>

<root>

  <tutorial>

    <id>T000001</id>

    <id>T000002</id>

    <id>T000003</id>

  </tutorial>

</root>


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

An immediate job opportunity as a B
Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C

View all Jobs (Add yours)
View all CV (Add yours)



answering service
conference call services
swimming pool builder
affordable conference calls
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP