|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Paths, node sorting & node constructorsMichael Kay mike at saxonica.comSat Mar 15 11:13:09 PST 2008
> 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






