[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Grouping


Subject: Re: [xsl] Grouping
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Jan 2002 09:59:51 -0500

At 2002-01-21 06:29 -0800, Maarten Meussen wrote:
I've been stuck on the next problem for a few days
now, eventhough the answer must be real simple ( I
think), I cant figure it out.

Multiple-level sorting with the pure Muenchian method involves divining a key combination that is unique at each level of the key sort and then recombining this for each node being tested.


Personally, I find that sorting sub-groups is a lot easier using variables instead of using key tables.

You don't give enough data to write a quick test file, but here is the outline of the code structure:

<xsl:variable name="firsts" select="XPath-of-first-level-sort-nodes"/>
<xsl:for-each select="$firsts">
  <xsl:if test="generate-id(.)=
                generate-id($firsts[XPath-of-unique-value-calculation])">
    <!--first-level grouping completed-->
    <xsl:variable name="seconds" select="XPath-relative-for-seconds">
    <xsl:for-each select="$seconds">
      <xsl:if test="generate-id(.)=
                    generate-id($seconds[XPath-of-unique])">
        <!--second-level grouping completed-->
        ...etc....
      </xsl:if>
    </xsl:for-each>
  </xsl:if>
</xsl:for-each>

I hope the above helps.

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


-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002

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 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & 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:  02-02-11,12,14,15,18,21,03-04,05,06,08,11,
-                                04-08,09,10,12,05-14,15,06-04,07


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




Current Thread
Keywords