RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Peek Into the Future of XSLT 2.0 : Page 7

XSLT 2.0 provides powerful new features that XSLT 1.0 was missing. Although XSLT 2.0 is still under development, Mike Kay's Saxon 7 implementation lets you experiment with the new capabilities now.

Grouping Made Even Simpler
Now for the fun part. You can accomplish the same sort of grouping demonstrated in the last example with the for-each-group statement using only an expression. Here's another way to group the costs:

   <xsl:variable name="cost" 
      select="for $x in /products/prices/price[name = 
      $name], $y in self::* return $x/cost" />
Examine the expression in the select attribute and you can see that it's the equivalent of the for-each-group statement shown earlier. You can find the code for this alternate grouping scheme in the file Listing5.xsl, which is included in the downloadable sample code for this article.

XSLT 2.0 addresses many of the concerns XSLT developers have raised. It turns grouping into a simple and directly manageable task, reduces the dependence on extensive recursive templates for string manipulation routines, deals with the issue of node-set access, and introduces the notion of multiple output documents, to name just a few.

Whether these new capabilities will result in broader usage remains to be seen. Although it's natural to think that some developers will look at XQuery as a competing language for XML processing, I tend to think the opposite—that widespread adoption of XQuery will actually expose more people to XSLT, because they're both so closely linked to XPath.

The two languages serve different purposes. XSLT was never intended to be a query language, although people have used it that way for lack of alternatives. XQuery is not intended to be a transformation language, but should see substantial use as a querying tool or application-level interface, particularly within the scope of native XML data sets in databases.

I haven't covered every new feature of XSLT 2.0 in this article. For a more complete list, see Elliotte Rusty Harold's slide presentation introducing XSLT 2.0, XPath 2.0, and XQuery.


Charles White  is President and Chief Executive Officer of The Tumeric Partnership, a firm focused on XML-driven Web application development that can be found at www.tumeric.net. He is the author of several Web development books, including "Mastering XSLT" from Sybex Books. He can be reached at chuck@tumeric.net
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date