Lists Home |
Date Index |
David Carlisle wrote:
> What seems strange to many people though is why the W3C docs don't
> describe (and possibly even define) Xquery as a cut down version of
> XSLT, with an ad-hoc syntax. That is, essentially, what it is isn't it?
Or maybe XSLT is a cut down version of XQuery that doesn't have FLWOR
expressions and an XML syntax?
There's certainly a lot of overlap in the two languages, especially in
path expressions and construction. The main difference is in the way
transformations are done - using template matching in XSLT, and using
FLWOR expressions in XQuery. But these are really at the heart of the
two languages. Programming in XSLT is fundamentally recursive,
programming in XQuery is more like writing queries.
There are other significant differences. XSLT is really two languages
loosely coupled together. About 80% of the syntax of XQuery is shared
with XPath, but instead of embedding XPath in a different language for
construction and transformation, it adds construction and transformation
directly to the language.
And the languages were designed for different purposes. XSLT was
designed for the transformations used in formatting applications, which
is why we speak of XSLT stylesheets. XQuery was designed as a query
language, but also to handle many of the more 'XML programming' oriented
scenarios found in our use cases.
> It may be that restricting the features of XSLT allows the system to be
> more readily optimised for dataabse queries, and this is no doubt a
> useful thing to do, but if that's what you are doing, why describe it as
> a completely new language?
We describe XQuery as a superset of XPath, and generate both documents
from the same XML source. And we widely advertise this fact. If there's
a clearer way to indicate that the languages are related, please feel
free to suggest it.