[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Keys and select distinct - is that the solution ?

Subject: Re: Keys and select distinct - is that the solution ?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 05 Jun 2006 12:30:29 -0400
select distinct efficiency
Hi,

Personally I think the "Muenchian method" is only difficult because we treat it as if it were difficult.

All it does is

* select one representative node from each group (usually the first
  in document order)
* iterate over this set
  * with each representative, process the rest of its group

The only reason it's hard at all is that in order to do these things efficiently in XSLT 1.0 we have to do things like node-identity tests (are you the first node in the group to which you belong?), which are just a bit tricky. Steve's particular contribution was to use keys for indexing, making expensive tree-traversals unnecessary when doing this. The basic algorithm might be clearer and easier to understand if we did it without keys -- but the efficiency gains are so enormous that we almost always have to use them. Hence the Muenchian method becomes "standard" even while it is somewhat more opaque (beginners often find keys a bit much to take in), and looks more complicated than it actually is.

It may be worth $45 to learn, but that's hardly the going market rate. Many many people have learned it for free.

As for "the man himself", Steve is nothing but gracious, and would probably be first to acknowledge that although he conceived the solution (or rather, imaginatively applied it from another domain: see http://www.biglist.com/lists/xsl-list/archives/200005/msg00270.html), it also emerged from within the context of a community-wide effort to address a number of variously-related transformation requirements including grouping, in which many other people played significant roles (including several still active here such as Mike Kay, David Carlisle, Ken Holman -- read the archives and FAQ to see who).

The first three or four years of XSLT were lots of fun, and a very impressive demonstration of how much more powerful than one mind (even one mind like those mentioned above) can be many working cooperatively.

Cheers,
Wendell

At 07:29 PM 6/2/2006, you wrote:
Christian Rasmussen <christiankrasmussen@xxxxxxxxx> writes:

> These are grouped in elements of ManureTypeCodes and ManureTypeNames

sounds like some projects I've worked on ...

I have nothing really substantial to offer here, except to emphasize
that in XSLT2 this becomes extremely simple.  so my advice is to
very seriously consider using XSLT2.

that is, for various reasons, sometimes not an option.  in that case
you probably need to understand the so-called muenchian method, since
that technique is the only general purpose grouping method I know of
in XSLT1.  it's certainly not beginner level XSLT, but given a
moderate investment in puzzling it out, is not as they say rocket
science.

in fact, I learned the method from (indirectly) the man himself:

  Building Oracle XML Applications
  Steve Muench

At $44USD, it's not cheap, but it contains a section on the eponymous
method, with nice pictures and a thorough walk through.  it still took
me several tries before I really felt comfortable with the idea, but
if you're going to be doing any serious XSLT1 work, it's something you
pretty much need to understand.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.