This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Seeking help on Grouping distingt sub-elements


At 2002-05-06 15:06 -0400, jestoll@crtnet.com wrote:
>Ken, on your statement:
>
><xsl:if 
>test="generate-id(.)=generate-id($chassis[commonid=current()/commonid])">
>
>is there an implied [1] on the end of the $chassis[...] piece?

Only by coincidence ... generate-id() (and a number of other functions) 
operate only on the first node in document order of a node set argument of 
more than one node.  So it *looks* like there was a [1] there, but that's 
not what is going on behind the scenes.

>Having looked at Ken's, Jeni's was a bit more aproachable (still a little 
>wierded out by the key thing after the recent head-bashing...) - it 
>appears that they're doing the exactly the same thing - Ken's is using a 
>for-each immediately followed by an if that compares the generate-id 
>values, while Jeni's uses a for-each with the equivalent key-based 
>approach - is that correct?

Yup!  I came across my method when I was obliged to use XT and XT didn't 
support keys.  I find it far easier to handle "contextual grouping" be that 
in a subset of the tree (as in your case) or when grouping within groups (a 
common requirements).  Also, having the variable around was helpful in your 
situation (though the reason I use the variable is for speed, in order to 
get away from having to access the source node tree more than necessary).

But, as I said, it isn't as "good" as the Muenchian method in certain 
situations, which I think all reduce down to when you need a node set 
result of the group members, in which case you have to use the Muenchian 
method.

My method only works when you are processing nodes as they are being 
selected, but I've been really pleased how much easier the subgrouping 
is.  I've added this method to the Muenchian method and the axis-based (but 
slow) method of grouping in the Sorting chapter of my electronic book.

This technique came to mind after the Ninth Edition of my electronic book 
went to paper, so you won't find it in the paper rendition of my book found 
in bookstores.

>I think its actually making some sense now!!! :-)

Congratulations ... it is a fun language to learn (and to teach!).

.............. Ken


--
Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002
-       : 3-days XML Information Modeling: July 31-August 2, 2002

G. Ken Holman                mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:               2002-05-06,07,09,10,13,15,20,
-                    06-04,07,10,11,13,14,17,20,07-31,08-05,27,30


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]