RE: XQuery WG comments on XProc specification

> > The other observation made in discussion was about the 
> requirement for 
> > the pipeline to be able to generate a query that is then 
> executed. ...
> 
> I think our spec may be misleading on this point. I had 
> imagined that c:query was a wrapper around some well-formed 
> XML. So you might write:
> 
> <c:query>
> default element namespace="http://www.w3.org/1999/xhtml"
> <html>
> <head>
> <title>Dumb query</title>
> </head>
> <body>
> </body>
> </html>
> </c:query>
> 
> Is it really the case that there are queries which aren't 
> well-formed XML? And can we just not support them, or are they common?

The thing most likely to make the query non-well-formed XML is an operator:
<, <=, or <<. These can be escaped, of course, but this creates a variant
representation of XQuery that's not necessarily trivial to convert to or
from the standard syntax. (The rule is that &lt; is an operator if it is
outside an element, or if it is within curly braces but not within
quotes...)

I would think it is also quite common for a query not to be
namespace-well-formed, because namespaces can be declared in the query
prolog (or implicitly in the case of well-known namespaces like the XML
Schema ns).

There are exotic queries that are not well-formed XML for other reasons, for
example <a a="{<b b="{<c/>}"/>}"/>, but I think one can decide to disallow
them.

XQuery largely uses entity and character references in a way that is
consistent with XML, but is selective about where they are expanded. For
example, <query>$x = "&quot;,&quot;"</query> would lose too much information
if the entity expansion is done by an XML parser.

I think XQuery needs a "less trivial embedding" for use with XProc and other
XML-based host languages.

Michael Kay
Saxonica

Received on Thursday, 26 June 2008 18:11:13 UTC