Templates in XQueryBrett Zamir brettz9 at yahoo.com
Sun Sep 5 12:32:11 PDT 2010
On 9/5/2010 5:22 AM, Martin Probst wrote: >> There really is a practical and philosophical problem with 2 "competing" XML >> transformation languages (and yes I 'dare' say xquery is a transformation >> language). > I wouldn't agree. To me, XQuery is an XML aggregation language. I > never do any significant XML transformation work using XQuery. Outside of the important omission of templates or the handful of features from XSL which have no equivalents in XQuery, what transformation feature of XSL cannot be expressed in XQuery and more succinctly so? For coders like myself who like to use light-weight programming tools without auto-complete on, I find XSL very cumbersome; there's nothing wrong with the processing, it's the syntax. With XQuery, you don't have to type namespace prefixes like "xsl:" everywhere for example, as you're working with a different syntax. And it's much clearer to read XQuery where you can see at a glance what part is output XML and what part is processing language. I think this clear visual distinction explains the popularity of say templating languages like Smarty in PHP over strictly XML-based ones, despite some of the latter's admitted inherent advantages. Discussions about the "right tool for the job" pertain more to existing implementations, rather than language design (and even for implementations I see this phrase often over-applied). And as far as the consequences for such a proposed change on implementations, while it could be handy for the likes of XML databases retooling themselves to allow complete transformations via XSL-style templating, by suggesting it as an optional feature, I'd be more hoping existing XSL implementations could allow swapping of their parsing layer (if it can indeed be that simple), giving XQuery syntax as an option, rather than forcing existing XQuery implementations to start supporting the push-based processing of templates). This is not to say there is not a valid basis of a best practice discussion weighing the value of relying on transformational constructs like templates vs. targeted constructs like for...in (or for-each) in different contexts, as these are indeed different "tools" suited for different situations, but XSL already offers both types, and I see no reason why XQuery could not, as a syntax, do the same. best wishes, Brett
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format