[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

XQuery coding style: nested FLWOR expressions

John Snelson jsnelson at sleepycat.com
Wed Apr 12 12:49:31 PDT 2006

nested for xquery
I think there are definitely two camps of XQuery writers. Those that 
have learnt XQuery because it is the "SQL of XML" are tainted by their 
SQL background, and often don't realise that you can write an XQuery 
statement without a FLWOR clause.

Those of us that approach XQuery from an XML, XPath and XSLT background 
(myself included) are used to the ideas of the context item, inline 
predicates etc.

I guess this is a symptom of the way XQuery was conceived, designed and 
marketed. However, I'm not really sure that one way is arguably superior 
to the other - query processors are just going to have to optimise both 
methods to the same execution strategy, eventually.

John Snelson

Michael Kay wrote:
> I've been looking again recently at some of the XMark benchmark queries.
> I'm wondering what it is about the language that makes people write things
> like this (Q9):
> for $p in /site/people/person
> let $a := for $t in /site/closed_auctions/closed_auction
>           let $n := for $t2 in /site/regions/europe/item
>                        where  $t/itemref/@item = $t2/@id
>                        return $t2
>              where $p/@id = $t/buyer/@person
>              return <item> {$n/name} </item>
> return <person name="{$p/name}">{ $a }</person>
> when they could have written
> for $p in /site/people/person
> return <person name="{$p/name}"> { 
>   for $t in /site/closed_auctions/closed_auction[buyer/@person = $p/@id]
>   return <item> {/site/regions/europe/item[@id = $t/itemref/@item]/name}
> </item> 
> } </person>
> Is it just a torture test for optimizers? Did the author think this was the
> best/easiest way to write the query? Does anyone else think it is? Is it the
> way SQL users' brains are wired?
> Michael Kay
> http://www.saxonica.com/ 
> _______________________________________________
> http://xquery.com/mailman/listinfo/talk
> http://xquery.com/mailman/listinfo/talk

John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc

Contracted to Sleepycat through Parthenon Computing Ltd


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.