RE: [XQueryX] 5 A Trivial Embedding of XQuery

> However the current section seems to indicate that unless it 
> has a mismatched < and so directly embedding the unquoted 
> query would produce non-well formed XML, the Query can be 
> simply inlined without quoting into an XML document.

In fact there are many other ways of writing a query that isn't
well-formed XML, for example 

<foo bar="{<zing zang="3"/>/@zang}"/>

is a legal XQuery. Moreover the following is legal both in XML and in
XQuery, but with completely different parse trees:

<foo bar="{<zing zang=" a="/>/@zang}"/>

Imagine putting that through an XML parser and the parser reversing the
order of the attributes!

I personally think it would be a good idea to define a subset of XQuery
syntax that parses correctly as XML, and is therefore safely embeddable.
I think the expressive power of this subset would be identical to the
current language, it would merely lose a bit of composability and place
restrictions on the use of character references. The only real problem
would be how to handle the "<" operator, which must be represented as
&lt; in XML but cannot be represented as &lt; in XQuery.

Michael Kay

Received on Thursday, 15 January 2004 07:48:25 UTC