Sign In/My Account | View Cart  
advertisement

Article:
 Architectural Style
Subject: XSLT - DOA?: An Opposing Viewpoint
Date: 2001-08-18 18:40:37
From: Kurt Cagle

I'm going to go out on a limb, and try to argue against the naysayers.


I've worked with XSLT extensively, and it has featured prominently in most books that I've written since 1999 (seven in all). I've heard this criticism come up quite frequently about the utility of XSLT versus its complexity, and inevitably there are those people who cite it as being 1) too complicated to write, 2) too limited in scope as an integration language, and 3) over-utilized to solve common problems.


I think all three of these points are in fact straw-men arguments. In the first case, the single biggest problem that XSLT faces is the fact that it is not a language for manipulating scalars but rather for manipulating sets. This point is frequently lost in articles by people who are attempting to work with it in the same way they work with procedural code, because the two paradigms are very different. Indeed, this is one of the great unifying factors between SQL and XSLT -- while in both cases you can do scalar operations with the languages, what you will have is a very bastardized format that cannot even hope to compare to the same operations done in binary compiled form, yet if you use either SQL or XSLT as a set manipulation language, you can create code of both astonishing simplicity and great power. Is such code more complicated to write? Sure -- you're dealing with data at a higher level, and you're working with a pattern recognition technology rather than a simple assignment language. That's the tradeoff you face.


Along those same lines, if you use XSLT using comparable technologies, you will get comparable results. Both Java and MS have the ability to create compiled stylesheets that work at speeds comparable to other compiled entities. They have the advantage that, because the source code can be referenced externally when needed, updating such XSLT source makes it easier to distribute and update changes to the component.


The second case strikes me as true, but vaguely silly. There are a number of purists who argue that XSLT needs to be kept as simple and pure as possible, because it is only a stylesheet language, and so have deliberately hobbled it. There are many others, myself included, who see it as an ideal language for integration, recognize that XSLT stylesheets, of all XML technologies, are the least likely to need to maintain device independence, and feel that it works very effectively as a binding or integration language. I remember back in the early 1990s when VB first appeared -- its detractors argued strongly that it was not a "pure" language and would in fact be little more than a toy. Yet it was the ability of this language to act as an easy to use binding agent that made it so immensely popular, even if it wasn't rigorously object oriented or pointer-centric.


XSLT has already spawned a number of variants that are nearly identical in most respects, save that they permit the use of extensions. If you bind a regular expression engine into a compiled translet, for instance, you are working not at interpreted speeds but at compiled ones, just as you would with any Java bean or COM object. The XSLT 1.1 working draft proposal was a significant move in the right direction, and it would have effectively solved many of the same issues that are repeatedly (and to a certain extent validly) brought up when criticising 1.0 - creating an output mechanism, creating a standard for extensions, even streamlining the language a bit so that the result of called templates could be invoked from within an XPath expression, rather than using the very roundabout mechanism that exists now (and then only by extension). This work is carried on in the EXSLT site and the people that participate in it, and by and large the solutions that they are coming up with work VERY effectively in creating integrated components.


However, XSLT 1.1 was basically dropped from the W3C agenda precisely because there are many people who fear that it gives too much power into the hands of programmers, which is another way of looking at James Clark's statement that XSLT 1.0 was only intended as a stylesheet language. A large number of languages that were intended for very limited applications tend to find utility beyond those applications, and they grow in strength and power accordingly. I think it is a mistake to argue that simply because the original designers never saw the use of this language in this way that is it should be deliberately hobbled because of that.


This gets to the third point. XSLT's use has grown dramatically in the last couple of years, which is actually rather remarkable when you look at the fact that: 1) it is not a commercial product, which means that relatively few people actually make any money off of selling licenses on it, and 2) it invokes a very different paradigm than what most people are used to when dealing with computer languages. Most people when working with XSLT either love it or hate it (and most of the ones that hate it are also people that are most used to thinking in scalar or pointer referential terms -- C++ developers for instance). There is typically a period of anywhere from a couple of weeks to a couple of months that you have to work with it before you begin to "grok" the language, but while the initial hump to understanding is fairly steep, once you have that basic level of understanding you begin to appreciate just how powerful the language is, and you begin finding applications for it that you would never have even considered before. I used a very quick XSLT script the other day to convert an XML document with all uppercase tags into one with all lowercase tags, something that would have been a pain to do either with DOM or with Javascript but was trivial with XSLT.


There are always applications that XSLT is not useful for, or that its more effort to write than its worth -- but I'm finding, so long as I'm willing to cut a few corners on how pure I make the language, that there are fewer and fewer apps that don't fall into that category, especially now that more applications work via the transmission or receipt of XML streams. I think this is worrisome to companies like Microsoft that first endorsed XSLT but are now becoming less emphatic about it as they realize that XSLT can obviate a significant amount of the advantages that their own, object based technologies offer.


I am definitely in the minority in my belief of this, but I continue to press it because I think that it is a valid and important viewpoint. Rather than limiting the utility of XSLT, look at where people are using it and expand it accordingly. Especially in comparison to XML Query, which I see as in several respects a step back, XSLT has the potential to be an integral component of XML development in the future.


-- Kurt Cagle
-- Co-author, Profession XSLT


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • XSLT - DOA?: An Opposing Viewpoint
    2001-08-24 12:35:39 Michael Maron [Reply]

    Agreed, I just want to add more on XML/XSLT vs SQL comparison.


    First, they are in the same boat as far as end users are concerned. They never deal with XML documents, XSLT stylesheets or SQL statements directly. All they see through the browser is Web site served by - hopefully - XML/SQL-enabled server-end application.


    Next, some history. I remember when SQL was an emerging technology, very complicated SQL statements were considered in literature to show its power: unions, subqueries, outer joins - all in one piece. A few computer eras later it appeared that with stored procedures it is more convenient to keep SQL statements reasonably simple and testable glewing them together with 3G code. My guess is, same thing is going to happen with XSLT. DOM-enabled apps can take proper care of reasonably straightforward stylesheets.


    Michael

  • XSLT - DOA?: An Opposing Viewpoint
    2001-08-21 07:17:53 Henry Naylor [Reply]

    I agree strongly. XSLT is an exciting and fun language to work in. When I first got the call to become our resident XML guru I found XSLT to be my worst nightmare. But as was said in the posting as I used it for the first few weeks and found a good book on the subject I fell in love.

  • XSLT - DOA?: An Opposing Viewpoint
    2001-08-20 08:29:44 Brad Clawsie [Reply]

    An interesting post and a good read, although I think it is useful to point out that the main proponents for XSLT posting to this board have written books on the technology, so I consider it in their vested interest to promote it (although obviously both posters saw some value in XSLT prior to writing the books).


    I think one thing that is generally overlooked in such debates is the general trends of technology adoption in IT. People are still integrating interpreted/memory-managed languages (Java/Perl/Python) into their codebases. Many shops are trying modelling tools for the first time. Some shops are still migrating to relational databases.


    Adoption of XML technologies in most shops is probably limited to pilot projects for document interchange needs. XML is good for this, but I would be surprised if XML adoption ever gets past this level. I have not heard one compelling argument why an XML transformation must itself be an XML document. True, you can reuse parts of your original XML parser to process the tree transformation, but then is this engine better suited for this task than mature VMs and compilers?


    Although XSLT allows you to separate document transforms from the rest of your business logic, is it ever really the case that real world apps decompose functionality that well? If a document transform is part of a larger function, why not just complete all tasks related to the function (arithmetic, database access, network access, for example) instead of breaking part of it out into a new syntax?


    Added to which, does the functionality of XSLT approach the data manipulation facillities of traditional languages? And by this I mean can similar functionality be expressed in comparable levels of verbosity? Every XSLT example I have looked it is utterly verbose compared to what could be cranked out in Perl.


    Brad






Sponsored By: