RE: [xml-dev] The use of XML syntax in XML Query

At 5:23 PM -0500 1/3/02, Champion, Mike wrote:


>Strong typing - There is a real-world use case for ensuring that queries
>return schema-valid results, for example ensuring that they can be displayed
>in valid XHTML.  (Whether anyone outside the W3C cares about schema-valid
>XHTML is another matter, but it is a "real world" example that I'm sure has
>counterparts with more data-oriented schemas in the REAL real world)

I'm interested in hearing more about this requirement. Personally, my 
general reaction is that the only thing that should be guaranteed out 
of an arbitrary XQuery result is well-formed XML. Any particular 
syntax beyond that is a question for the author of the query. By 
metaphor with SQL, a SQL SELECT statement produces a table. However, 
there's no guarantee that this table has the same schema as any other 
table in the database. It may or may not depending on what the SELECT 
statement did. I view XQuery similarly.

Suppose I do write an XQuery and I want its output to be valid 
according to some schema. If I run the query and it produces invalid 
data, then that's a bug in the query, which will likely be detected 
by a validation performed in a different, later layer. I will then 
fix my code, just as I would for any other bug.

What else would you want XQuery to do? Should it throw an exception 
of some kind? Return a default document? Start global thermonuclear 
war? What?

I view a query as a function that operates on an arbitrary 
well-formed XML document, and which kicks out a defined result for 
any well-formed document. If the results don't really make sense for 
some inputs, then I'll attach a validation layer to the input 
documents before I make the query. If I'm worried about what comes 
out of the documents, I'll attach a validation layer after the query 
has run to check the output. I'm just unclear on why this needs to be 
part of the XQuery layer.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+

Received on Thursday, 3 January 2002 18:30:08 UTC