469,332 Members | 7,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Muenchian Grouping Method for Multiple Levels

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

http://www.biglist.com/lists/xsl-lis.../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>

Aug 10 '05 #1
2 1805
Hi,
Tempore 15:36:39, die Wednesday 10 August 2005 AD, hinc in foro {comp.text.xml} scripsit reclusive monkey <re**************@gmail.com>:
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
Aug 10 '05 #2
Fantastic Joris, I changed the level3group variable to the syntax you
suggested and it now works perfectly. Many thanks to your keen xslt eye!

Aug 10 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.