Muenchian Grouping Method for Multiple Levels

Discussion in 'XML' started by reclusive monkey, Aug 10, 2005.

  1. I followed the instructions from the all-knowing Ms. Tennison here;

    http://www.biglist.com/lists/xsl-list/archives/200101/msg00070.html

    And it works great for the first two levels. However, when I tried to
    apply it to three levels, the third level just doesn't show. I am sure
    its something obvious but I just can't spot it. Can anyone see where I
    have gone wrong? Thanks in advance.

    Sample from XML file;

    <qrySubjectiveBuild1>
    <FLDivisionA>0</FLDivisionA>
    <FLDivisionADescription>Employees</FLDivisionADescription>
    <FLDivisionB>00</FLDivisionB>
    <FLDivisionBDescription>Salaries</FLDivisionBDescription>
    <SubjectiveCode>0000</SubjectiveCode>
    <SubjDesc>Teaching Staff- Teachers Scheme</SubjDesc>
    <CentrallyControlled>0</CentrallyControlled>
    <SCSDNonUse>0</SCSDNonUse>
    </qrySubjectiveBuild1>
    <qrySubjectiveBuild1>
    <FLDivisionA>0</FLDivisionA>
    <FLDivisionADescription>Employees</FLDivisionADescription>
    <FLDivisionB>00</FLDivisionB>
    <FLDivisionBDescription>Salaries</FLDivisionBDescription>
    <SubjectiveCode>0001</SubjectiveCode>
    <SubjDesc>Tutors</SubjDesc>
    <CentrallyControlled>0</CentrallyControlled>
    <SCSDNonUse>0</SCSDNonUse>
    </qrySubjectiveBuild1>

    (goes from 0001 to 9999 essentially)

    and the extract from the XSL file (the page displays fine, just without
    the third digit level, so I am happy the issue is within this code)

    Keys at top of XSL file;

    <xsl:key name="first-digit" match="qrySubjectiveBuild1"
    use="FLDivisionA"/>
    <xsl:key name="second-digit" match="qrySubjectiveBuild1"
    use="concat(FLDivisionA,' ',FLDivisionB)"/>
    <xsl:key name="third-digit" match="qrySubjectiveBuild1"
    use="concat(FLDivisionA,' ',FLDivisionB,' ',SubjectiveCode)"/>

    Grouping code;

    <ul>
    <xsl:for-each
    select="//qrySubjectiveBuild1[generate-id(.)=generate-id(key('first-digit',FLDivisionA))]">
    <xsl:sort select="FLDivisionA"/>
    <li><a name="{FLDivisionADescription}"><xsl:value-of
    select="FLDivisionA" /> - <xsl:value-of
    select="FLDivisionADescription" /></a></li>
    <ul>
    <xsl:variable name="level2group" select="key('first-digit',
    FLDivisionA)" />
    <xsl:for-each
    select="$level2group[generate-id()=generate-id(key('second-digit',concat(FLDivisionA,'
    ',FLDivisionB))[1])]">
    <li><xsl:value-of select="FLDivisionB" /> - <xsl:value-of
    select="FLDivisionBDescription" /></li>
    <ul>
    <xsl:variable name="level3group"
    select="key('second-digit',FLDivisionB)" />
    <xsl:for-each
    select="$level3group[generate-id()=generate-id(key('third-digit',concat(FLDivisionA,'
    ',FLDivisionB,' ',SubjectiveCode))[1])]">
    <li><xsl:value-of select="SubjectiveCode" /> - <xsl:value-of
    select="SubjDesc" /></li>
    </xsl:for-each>
    </ul>
    </xsl:for-each>
    </ul>
    </xsl:for-each>
    </ul>
     
    reclusive monkey, Aug 10, 2005
    #1
    1. Advertising

  2. reclusive monkey

    Joris Gillis Guest

    Hi,
    Tempore 15:36:39, die Wednesday 10 August 2005 AD, hinc in foro {comp.text.xml} scripsit reclusive monkey <>:

    > I followed the instructions from the all-knowing Ms. Tennison
    > And it works great for the first two levels. However, when I tried to
    > apply it to three levels, the third level just doesn't show. I am sure
    > its something obvious but I just can't spot it.
    >
    > <ul>
    > <xsl:for-each
    > select="//qrySubjectiveBuild1[generate-id(.)=generate-id(key('first-digit',FLDivisionA))]">
    > <xsl:sort select="FLDivisionA"/>
    > <li><a name="{FLDivisionADescription}"><xsl:value-of
    > select="FLDivisionA" /> - <xsl:value-of
    > select="FLDivisionADescription" /></a></li>
    > <ul>
    > <xsl:variable name="level2group" select="key('first-digit',
    > FLDivisionA)" />
    > <xsl:for-each
    > select="$level2group[generate-id()=generate-id(key('second-digit',concat(FLDivisionA,'
    > ',FLDivisionB))[1])]">
    > <li><xsl:value-of select="FLDivisionB" /> - <xsl:value-of
    > select="FLDivisionBDescription" /></li>
    > <ul>
    > <xsl:variable name="level3group"
    > select="key('second-digit',FLDivisionB)" />


    At first sight, this line jumps out. I believe it must be more like this:
    <xsl:variable name="level3group"
    select="key('second-digit',concat(FLDivisionA,' ',FLDivisionB))" />

    > <xsl:for-each
    > select="$level3group[generate-id()=generate-id(key('third-digit',concat(FLDivisionA,'
    > ',FLDivisionB,' ',SubjectiveCode))[1])]">
    > <li><xsl:value-of select="SubjectiveCode" /> - <xsl:value-of
    > select="SubjDesc" /></li>
    > </xsl:for-each>
    > </ul>
    > </xsl:for-each>
    > </ul>
    > </xsl:for-each>
    > </ul>




    regards,
    --
    Joris Gillis (http://users.telenet.be/root-jg/me.html)
    Vincit omnia simplicitas
    Keep it simple
     
    Joris Gillis, Aug 10, 2005
    #2
    1. Advertising

  3. Fantastic Joris, I changed the level3group variable to the syntax you
    suggested and it now works perfectly. Many thanks to your keen xslt eye!
     
    reclusive monkey, Aug 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tristan Miller

    XSL grouping (Muenchian)

    Tristan Miller, Jan 31, 2005, in forum: XML
    Replies:
    2
    Views:
    571
    Philippe Poulard
    Jan 31, 2005
  2. Replies:
    1
    Views:
    650
    Joris Gillis
    Jun 6, 2006
  3. Replies:
    1
    Views:
    656
  4. Jeffrey
    Replies:
    0
    Views:
    352
    Jeffrey
    Feb 28, 2009
  5. Jeffrey
    Replies:
    0
    Views:
    700
    Jeffrey
    Feb 28, 2009
Loading...

Share This Page