giovedì, gennaio 21, 2010

XSLT: Microsoft's XSLT 2 and Grouping Using the Muenchian Method in XSLT 1

Here are some great insights on XSLT. They are rather unrelated except for the one thing I was looking up: grouping in XSLT. It turns out, there is a grouping function in XSLT 2.

*

First, an article from Tech Talk entitled “Where is Microsoft's XSLT 2?” discusses one blogger’s efforts (and frustrations) with Microsoft not implementing XSLT 2. Here is an excerpt he has at the end of the article from Microsoft:

“While XML continues to be a key part of our platform going forward, we have decided not to pursue an XSLT 2.0 implementation at this time. If there is a specific XSLT task you’re trying to accomplish and are having difficulty with XSLT 1.0, please let us know and we’ll do our best to help.”

*

The main interest I had in XSLT 2 was the new grouping function. It turns out there is a method to accomplish this in XSLT 1. Jeni's XSLT Pages has this great article: “Grouping Using the Muenchian Method.”

“The Muenchian Method is a method developed by Steve Muench for performing [grouping] using keys. Keys work by assigning a key value to a node and giving you easy access to that node through the key value. If there are lots of nodes that have the same key value, then all those nodes are retrieved when you use that key value. Effectively this means that if you want to group a set of nodes according to a particular property of the node, then you can use keys to group them together.”