|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] XQuery and id()/idref(); Controlling the children of nodes in the result sequenceMichael Kay mike at saxonica.comThu Apr 24 11:04:19 PDT 2008
On any of these formulations, Saxon will return a result for the predicate (x intersect y) as soon as if finds a node that is present in both sets. What it won't do is to recognize that if the predicate is false for a particular node, then it also false for its descendants. The (x intersect y) formulation is better than (some $x in x, $y in y satisfies $x is $y) because in the first case Saxon will use a sort-merge strategy (with the sort often being unnecessary, because in many cases the operands will already be in document order); in the latter case it will use two nested loops. Internally, when you use an expression whose static type is node()* in a context where the effective boolean value is required, Saxon wraps the expression in a call on exists(), because this avoids executing the general EBV algorithm at run-time. The exists() function also rewrites its operand to avoid sorting, for example exists(ancestor::x) is effectively rewritten as exists(unsorted(ancestor::x)). Michael Kay http://www.saxonica.com/ > Andrew Welch wrote: > > Hi > > > if you rewrote > > > not(ancestor::* intersect $e) > > > to be > > > not(some $x in ancestor::* satisfies $x is $e) > > That's not the same thing because 'is' compares two nodes. > So your second expression would be rather equivalent to: > > not(ancestor::* intersect exactly-one($e)) > > I'd say you should write instead: > > not( > some $x in ancestor::* satisfies > some $y in $e satisfies > $x is $y > ) > > I didn't test them, but I guess even a naive processor > would have enough info in the second case to know it can stop > as soon as it finds a node that satisfies the identity > (because of 'some'). > > For the first case Saxon seems to wrap the intersection > into an 'exists' instead of 'not', and I am confident that in > this case it stops when it finds a node. But Mike can tell > you more on that. > > But when I see the two expressions, my first reaction is to > prefer to trust my processor's optimizer and make the intent > as clear as possible for other developers... > > Regards, > > --drkm > > > > > > > > > > > > > > > > > > > > __________________________________________________ > Do You Yahoo!? > En finir avec le spam? Yahoo! Mail vous offre la meilleure > protection possible contre les messages non sollicités > http://mail.yahoo.fr Yahoo! Mail > > _______________________________________________ > http://x-query.com/mailman/listinfo/talk > http://x-query.com/mailman/listinfo/talk
|
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
|






