473,383 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 1952
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rayt | last post by:
I’m relatively new to XSLT and must admit I’m finding it refreshing, but every now and again something comes along which floors me. Maybe it’s the old imperative language background that is hard to...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
1
by: lennyw | last post by:
Hi I'm trying to use XSLT to do an xml to xml transformation where the output xml contains summary data on the information in the input xml. I've succesfully done a Muenchian grouping of the...
1
by: aleksander.hansen | last post by:
Hello, I have xml data that I need to group and sort. I have tried grouping it using the Muenchian Method. Probably not solved the best way, but it works. But I can't get the sorting right. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.