Re: Two-level grouping problem
Hi, Max, The algorithm in Ken's stylesheet goes like this: 1. Read the records into a variable. 2. For each record in the variable, get each member of the set that has distinct type and subtype values (this is the outer group). 3. Read the outer group records into a variable. 4. For each record in the outer group, get the first of the records with a distinct code value (this is the inner group). The particular statement you quoted ensures that the outer group contains only unique values. This statement permits the first record with a particular type and subtype to get to the rest of the process and blocks the following ones. That happens because the predicate always finds the first matching record. So, when the second (or later) record with those characteristics hits the if statement, it fails because it has a different ID than the one the predicate matches. (The predicate is the part within the brackets: [TYPE/@value=current()/TYPE/@value and SUB_TYPE/@value=current()/SUB_TYPE/@value]). Ken isn't assigning an ID in that statement. He's using the fact that an XSLT processor must generate unique IDs for every element to get just one from a set of several identical elements. In that fashion, he cracks the grouping problem. I hope I have been sufficiently clear. I also hope I have not been overly pedantic, but I know you are new to XSLT. Jay Bryant Bryant Communication Services (presently consulting at Synergistic Solution Technologies) Max Bronsema <max.bronsema@xxxxxxxxx> 05/10/2005 12:26 PM Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx To xsl-list@xxxxxxxxxxxxxxxxxxxxxx cc Subject Re: Two-level grouping problem Hi Ken, http://www.xslt.com/html/xsl-list/2002-05/msg00486.html At the above link I would appreciate help in understanding this snippet of xslt. ================================================================ <xsl:if test="generate-id(.)= generate-id($rows[TYPE/@value=current()/TYPE/@value and SUB_TYPE/@value=current()/SUB_TYPE/@value])"> ================================================================ Is $row comparing different nodes and making sure they are equal or is this just setting the id for both TYPE and SUB_TYPE? Or am I just totally out in left-field? Thanks, Max Bronsema On 5/9/05, G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote: > At 2005-05-09 09:42 -0700, atlstjohn@xxxxxxxxx wrote: > >Im having a frustrating time getting multi-level > >grouping to work as expected. Ive tried every variant > >of the muenchian method I could think of > > I find multi-level grouping is more easily handled using a variable-based > grouping method, because the Muenchian method works with document-wide scope. > > You'll find various archives with posts such as the following showing examples: > > http://www.xslt.com/html/xsl-list/2002-05/msg00486.html > > http://www.biglist.com/lists/xsl-list/archives/200401/msg00340.html > > I hope this helps. > > . . . . . . . . Ken > > -- > World-wide on-site corporate, govt. & user group XML/XSL training. > G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx > Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ > Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) > Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc > Legal business disclaimers: http://www.CraneSoftwrights.com/legal
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format