For all these queries, implementations have the option whether to
evaluate the base expression (error()) before or after evaluating the
predicate. If the value of a predicate doesn't depend on the focus,
rewriting A[B] as "if (B) then A else ()" is a good thing to do, so many
processors will do it.
The only reliable way to generate an error conditionally is to use
if/then/else (or typeswitch):
if (contains('http:...', 'details')) then error() else ...
There are specific rules for conditional expressions that prevent
optimizers evaluating the then/else branch unless the condition is
true/false.
Michael Kay
Saxonica
On 21/01/2013 11:07, Yoshi Okamoto wrote:
Dear list subscribers,
I noticed that different XQuery processors (BaseX,
Saxon, XMLPrime, Zorba) return different results for the following queries:
Query A:
fn:error()[false()]
Query B:
error(())[contains('http://....', 'details')]
Query C:
let $url := <url>...</url>
where contains($url, 'details')
return error(())
All except for XMLPrime return an empty sequence.
Query D:
let $url := <url>...</url>
return error(())[contains($url, 'details')]
All except for Zorba return an error.
My original intention was to raise an error whenever a certain condition is
true. My questions would be:
- what are the correct results for Query A-D?
- XMLPrime is the implementation that always raises an error. If this behavior
should be correct, how would I proceed to only raise errors under a certain
condition?
Thank you for your attention and patience.
Best regards
Yoshi OKAMOTO
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk