RE: Re: [xsl] New user issue: use of Muenchian method

Subject: RE: Re: [xsl] New user issue: use of Muenchian method
From: cknell@xxxxxxxxxx
Date: Fri, 21 Sep 2007 15:04:38 -0400
Dr. Egon Spengler: There's something very important I forgot to tell you. 
Dr. Peter Venkman: What? 
Dr. Egon Spengler: Don't cross the threads. 
Dr. Peter Venkman: Why? 
Dr. Egon Spengler: It would be bad. 
Dr. Peter Venkman: I'm fuzzy on the whole good/bad thing. What do you mean, "bad"? 
Dr. Egon Spengler: Try to imagine all life as you know it stopping instantaneously and every molecule in your body exploding at the speed of light. 
Dr Ray Stantz: Total protonic reversal. 
Dr. Peter Venkman: Right. That's bad. Okay. All right. Important safety tip. Thanks, Egon. 
Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Sent:     Fri, 21 Sep 2007 14:21:47 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: [xsl] New user issue:  use of Muenchian method

Hey Mike,

To cross with another thread --

At 10:05 AM 9/21/2007, you wrote:
><xsl:stylesheet version="2.0" ...

If you are using XSLT 2.0 I strongly recommend you investigate its 
native grouping facilities before investing too much energy into the 
Muenchian method, which is essentially a hand-made implementation of 
an algorithm to handle processing semantics that could have been much 
more deeply embedded in the language -- and which now, in XSLT 2.0, have been.

This having been said, what you are now doing isn't (yet) a 
full-blown example of the Muenchian method. So far as I can see, it's 
simply the (appropriate) use of a key to perform node traversal 
according to an association between nodes.

It seems to me that Ken has done his usual fine work analyzing your 
stylesheet, but there's one other possible problem I see:

>  <included-table>
>   <xsl:value-of select="text()"/>
>   <xsl:for-each select="key('entity-id','@id')">

.. you'd probably want select="key('entity-id',@id)". At present, 
you are using the string value "@id" as your key value -- probably 
not what you want.

It also appears that the basic issues you're having relate to the 
XSLT processing model -- how nodes are matched by templates and 
processed, and most especially how they're matched by templates and 
processed by default, even if you have no explicit logic for doing 
so. That's why Ken advises you also to read up on the built-in templates.

One thing I have students work out when they're at this stage is to 
run a stylesheet that *has no templates* and see if they can explain 
why they get the output they do.

The next thing I often have them do is try a stylesheet that has only 
a single template, which matches a single type of element deep in 
their tree. For example, you could have

<xsl:template match="Referenced_Entities">

.. and then explain the results of that. (Some people find the first 
task much easier after they've tried the second.)

It gets even more interesting if you had a second template to the mix:

<xsl:template match="Subject_AreaProps">

The key to all of it is in seeing what the templates are doing 
*together* -- which includes those helpful (but invisible) built-in templates.

Any XSLTer who can't tell you what you'll get and why is either still 
a beginner, or a poser. :-)


===================================================================== Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
   Mulberry Technologies: A Consultancy Specializing in SGML and XML

Current Thread