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

Paths, node sorting & node constructors

Michael Kay mike at saxonica.com
Sat Mar 15 11:13:09 PST 2008


  Paths
> One thing with XQuery that I am constantly tripping over in 
> XQuery is that the result of sorting constructed elements is 
> undefined. Consider this:
> 
> 	path/(<h3>{...}</h3>,
> 	      <p>{...}</p>)
> 
> 
> So what can one recommend users to do? To go away from 
> XPath-style, and use a for loop instead?
> 

Yes, I think using element constructors on the rhs of "/" is best avoided.

For a time I took to using $var/(long expression) as a way of causing (long
expression) to be evaluated
with $var as the context node. For example:

declare function copyCustomer ($c) {
  $c/
   <partner>
     <name>{@name}</name>
     <address>{address}</address>
   </partner>
}

But the document ordering semantics of "/" make this too dangerous. It works
in this case, but fails in many others.

XQuery desperately needs a "simple mapping operator": something that's like
a "for", but setting the context item rather than a variable, and without
any ordering semantics. This came up again and again during WG discussions,
but got defeated every time - partly because no one could find a way of
writing the operator that everyone liked. In fact, in the early days before
some of the XQuery WG members fully understood XPath, they wanted "/" to be
that operator - but of course that's incompatible with its existing usages.

Michael Kay
http://www.saxonica.com/

M



Purchase Stylus Studio Online Today!

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.
Email
First Name
Last Name
Company
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-2007 All Rights Reserved.