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

Re: pairing up similar tags based on an attribute

Subject: Re: pairing up similar tags based on an attribute
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 13 Oct 2006 12:10:40 -0400
Re:  pairing up similar tags based on an attribute
At 05:32 AM 10/13/2006, Andrew wrote:
On 10/13/06, Webmaster <Webmaster@xxxxxxxxxxx> wrote:
Hi.All.
Thank you for your responses.  It was really hard for me to explain my
situation, but I think you understood the question. I'm using XSL1.0, and am
pursueing the muechian method. And consequently pulling my hair out.

I'll let you know how it turns out.

The Muenchian technique is really hard to understand until the penny drops and you realise what all the generate-id()'s are for :)

This is quite true.


And what is the generate-id() for? To see if the nodes returned by two different expressions, for example

1. . (i.e., the context node)


2. key('items-by-group',$item-key)[1] (i.e., the first node in a given group, in document order)


are in fact the same node.

Actually what is "Muenchian" about the Muenchian method (though only keen historians of XSLT will ever know this) is not the grouping method itself, but the recognition that expression 2 can be used instead of this:

3. /descendant::item[@group=$item-key][1]

or, if you prefer, (//item[@group=$item-key])[1]

which work just as well in theory, but not in practice, as (a) these are harder for an XSLT processor to optimize to run fast (as $item-key isn't static), and (b) if it is not optimized, it scales far worse than expression 2. Using a key is in effect a way of optimizing the process by hand.

Once you get it though, you also get a whole raft of concepts that
really help in other areas of XSLT, so persevere with it and if you
get stuck post back.

That's also true.


The Muenchian method is also tricky because it's actually two or three separate non-obvious techniques used together. They'd be much easier to learn separately. But the "how" and the "why" can be distinguished; the method can basically be boiled down to

1. Grabbing a set of nodes according to a given selection criterion for grouping;
2. Grabbing all the available sets by grabbing all the nodes and filtering them, keeping only one member (typically the first in document order) from each set;
3. Using techniques for doing these that are reasonably performant and scalable over larger data sets, at the price of being somewhat opaque.


It would be much easier to learn that you were doing 1 and 2 if you didn't have to worry about 3. And again, 3 is the only part that is really "Muenchian", but the performance gains are so enormous that expert practitioners rarely or never bother with 1 and 2 without it.

Cheers,
Wendell

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.