[xquery-talk] Screen-scraping with XQuery

Michael Kay mhk at mhk.me.uk
Fri Apr 1 13:00:21 PST 2005

> Good question. I guess the issue is more "how can I embed an XQuery
> program within an XML document" than directly related to XPL. What
> happens if you escape the internal opening brackets within attributes:
> <a href="{concat("a", &lt;B>thing&lt;/B>}"/>
> Does this make a difference for XQuery?

Yes, it does. That's not a legal query any more. XQuery only allows &lt; in
character content or in string literals, not in places where an operator or
element constructor might be expected.

I guess it's no big deal for XPL if you only support the subset of XQuery
that's well-formed XML. It's easy enough for users to avoid such constructs
(and probably good practice).

More of a practical issue are the operators such as "<", "<=" and "<<" which
in XQuery syntax must be unescaped. It's harder to avoid using these,
although you can always invert the operands and use ">", ">=", ">>".

(I'm actually trying to write a WG proposal on embedding XQuery in XML at
the moment. XPL is a good use case for it. I'm not happy with either XQueryX
or the "trivial embedding" where all "<" characters are escaped. I would
like to see something defined along the lines that XPL uses, but it
obviously needs to be specified more precisely for a spec than one often
does in a product.)

Michael Kay

> -Erik
> Michael Kay wrote:
>  > One thing this reminds me of: do you have any formal definition of 
> how you
>  > embed the XQuery syntax in XPL? For example, how do you 
> handle constructs
>  > like
>  >
>  > <a href="{concat("a", <B>thing</B>}"/>
>  >
>  > which are valid in XQuery but not in XML?
>  >
>  > Michael Kay
>  > http://www.saxonica.com/
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk

More information about the talk mailing list