Muenchian Grouping Method for Multiple Levels

R

reclusive monkey

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>
 
J

Joris Gillis

Hi,
Tempore 15:36:39 said:
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,
 
R

reclusive monkey

Fantastic Joris, I changed the level3group variable to the syntax you
suggested and it now works perfectly. Many thanks to your keen xslt eye!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top