RE: [xsl] XQuery and XSLT

Subject: RE: [xsl] XQuery and XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 17 Nov 2006 09:20:47 -0000
I've written on this a couple of times:

My own view (and my own usage) is to use:

* XQuery for small jobs, XSLT for large ones

* XQuery for extracting facts, XSLT for presenting or transforming documents

The two big things that are missing from XQuery are template rules and
import precedence. Together, the absence of these features makes it much
more difficult to write flexible code that can be adapted and reused to
handle different kinds of input document or produce different kinds of
output. There are also many smaller things missing, such as grouping, date
and number formatting, control over serialization.

As a transformation language, one area where XQuery is very weak is for
tasks that involve making a few changes to a document while leaving most
things unchanged - for example, deleting all the Note elements. Eventually
XQuery Update will solve this problem, but for the moment, XSLT wins hands

The main advantage of XQuery is that it is more concise (less verbose).
That's a great advantage when you want to do a one-off enquiry ("list me the
tests where Saxon's result differed from the published result") - it becomes
a one-liner that you can do straight from the command line, rather than
loading up your IDE. But as soon as you want to turn this one-liner into a
more sophisticated report, which can be run repeatedly, my personal choice
would be XSLT. When the application has a long life, a bit of verbosity does
no harm. The test results which the XQuery working group presented to Tim
Berners Lee yesterday were formatted using XSLT.

As for learning, there is good experimental evidence that XQuery is easier
to learn. This isn't surprising: it's a smaller and more concise language,
and the rule-based programming style that works best with XSLT is unfamiliar
to many people new to the language. For professionals working with XML every
day, however, I think you need both tools in your kitbag: and 90% of the
learning is transferable between them.

Michael Kay


> -----Original Message-----
> From: Jesper Tverskov [mailto:jesper@xxxxxxxxxxx] 
> Sent: 17 November 2006 07:07
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] XQuery and XSLT
> Hi list
> As a fan of XSLT and almost addicted to it, I am surprised to 
> learn that XQuery is not just for views joining documents, 
> filtering, grouping and sorting, but that XQuery is also 
> great for transformations like XML to HTML and XML to XSL-FO/pdf.
> I am wondering: What are the strong and weak sides of XQuery 
> and XSLT making it necessary to learn both?
> Cheers,
> Jesper Tverskov

Current Thread