Re: [xml-dev] XSLT and XQuery

James Clark wrote:

> Template rules are just syntactic sugar for a recursive function call and a
> case statement, both of which XQuery has (doesn't it?).  I would be inclined
> to nominate some of the axes (almost everything but children and
> descendants) as the prime things to exclude from XQuery, both because they
> are hard to optimize and hard to statically type in any sort of useful way.

If you remove the ancestor and parent axes, it's very difficult
to replace a set of template rules with a case statement.

The most natural way to test a context node against a match
expression is to run the expression "in reverse", e.g.,
to match a node against "a/b//c", check if the current node is
a 'c', some ancestor is a 'b', and that node's parent is an 'a'.

You *could* interpret the XSLT Rec literally (evaluate the
pattern "a/b//c" against each node in the document and check
if the context node shows up in any of the results), but that's
obviously not a very good approach.

That said, I agree that it would be a good idea to leave template
rules out of XQuery and only allow the self::, children::, descendants::,
and descendants-or-self:: axes.  These features are essential
for XSLT, but they're one of the main reasons XSLT is so hard
to optimize and don't appear to be necessary for any of the XQuery
use cases.


--Joe English

  jenglish@flightlab.com

Received on Friday, 4 January 2002 12:17:02 UTC