Talk:XQuery/Typeswitch Transformations

I think a better pattern here would be to move the FLWOR to the recurse function, and let main just do the typeswitch. One of the most helpful articles on typeswitch is MarkLogic's application developer guide (see Chapter 8, "Transforming XML Structures With a Recursive typeswitch Expression"). Instead of main and recurse, the functions there are called dispatch and passthru. Function names aside, I think the FLWOR rightly belongs outside of the typeswitch. Joewiz (talk) 23:54, 12 June 2010 (UTC)

I think there are a number of misleading statements on this page. (It's also very confused about whether it's trying to be even-handed or not.)

Firstly, it's true (there is evidence) that the learning curve for XSLT is longer than for XQuery. This isn't surprising, as XSLT is a larger language. However, the evidence from those who have taught XSLT is that the main reason for this is that the rule-based approach to writing transformations is unfamiliar to most users. Yet this page is advocating a similar rule-based approach to transformation using XQuery, which does not have built-in language support for the feature. If you have to learn this coding pattern anyway, might it not be true that the benefits of XQuery in terms of learning curve disappear?

As for using XML syntax, it's true that many new users (especially those from a programming rather than authoring background) find this off-putting, but it's not true that it makes XSLT language harder to learn or that it reduces productivity. And it's not true that the feature of using XSLT to transform XSLT is "not wildly used" [sic]. It's used in nearly every non-trivial application of XSLT that I have seen. (By non-trivial, I mean an application that uses more than about 20 stylesheets).

The statement "In the face of these realizations and a number of new use cases, the W3C created a second language" is historical revisionism. The original group that created XQuery started work before XSLT was published, and for the first couple of years of their work they were largely unaware of XSLT; they were not interested in it because their aim was to create a database query language, and XSLT was not billed as such.

In comparing XSLTs template rules to what can be achieved with typeswitch, a key feature of template rules has been forgotten. This is that template rules can be overridden by more selective template rules using the notions of priority and precedence. Customizing a library of template rules by overriding selected rules is key to reuse with XSLT, and XQuery has no equivalent (at least, until higher-order functions appear in XQuery 3.0).

Michael Kay -

@Michael Kay: Thank you for your critique here. I agree with your points about the article's internal editorial confusion - I've completed an edit designed to impose editorial balance, while more clearly stating what proponents of the typeswitch method have found to be the advantages of an XQuery approach. More edits will hopefully come - including addressing self-transformation, priority, and precedence more rigorously. Joewiz (talk) 04:38, 19 December 2010 (UTC)