Re: XQuery

On Thu, Oct 16, 2003 at 11:20:57AM +0200, Guido Moerkotte wrote:
[...]
> 2) Some of us would like the query not to fail.
> 
>    Just as a reminder:
>    document:
>      <?xml version = "1.0"?>
>      <persons>
>       <person name="anton" age="two and a half"/>
>       <person name="anna"  age = "3"/>
>      </persons>
>    query:
>      for $p in document("p.xml")//person
>      where $p/@age = 3
>      return $p/@name

Personally I want that query to fail with an error, because my data is
not well formed.  Of course, then I want to go and fix the bug in my
W3C XML Schema instance that allowed the incorrect data.  Or, I go and
fix the bug in my query that failed to allow for the actual permitted
variation in my data.

In other words, my query has to match the data, and if it does not,
I don't want the query processer to bend over backwards to prevent
me from discovering my error.  It's *my* error in writing the query
incorrectly, or in loading bad data.

You might well say that it's an undue burden on query writers, and
in that case I think the answer is that a future version of XQuery,
once there is more experience in the field, may benefit from an
exception mechanism.

The strongest argument that we have a problem here is for XPath and
XSLT 1 compatibility in XSLT -- e.g.
    foreach $toddler /persons/person[@age &lt; 3]
would have silently failed in XSLT 1.

For one, I'm pleased that we'll now be able to detect this bug in
my data automatically, but it may be that there are use cases where
the older behaviour is desired, espcially in the absence of any Schema.

Detecting the bug in the document using XQuery is slightly tricker
I think, because we need to ask, can we cast this value to a number.

When it's easier to use a schema than a query, maybe the answer for
now it, use a schema.

Liam

-- 
Liam Quin, W3C XML Activity Lead, liam at w3.org, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/

Received on Thursday, 16 October 2003 15:00:16 UTC