473,226 Members | 1,681 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,226 software developers and data experts.

Muenchian problem

Hi,

I'm trying to apply Muenchian grouping to the XML displayed below but
having no success, I'm trying to group on the section element, any
pointers would be much appreciated:

Thanks,

Mike

---- XML ----
<?xml version="1.0" encoding="utf-8"?>
<page>
<attributes>
<pagename>The Band</pagename>
<name>the_band</name>
<menuname>The Band</menuname>
<pageidentifier>english/the_band</pageidentifier>
<status>open</status>
<lastedited></lastedited>
</attributes>
<containers>
<container name="content">
<elements>
<element type="BandMember">
<name>Luke Skywalker</name>
<section>Front Row Cornets</section>
<position>Solo</position>
<joined>1992</joined>
<composer>Gershwin</composer>
<musicpiece>Lazy Trumpeter</musicpiece>
<bandmoment>something</bandmoment>
<notes></notes>
</element>
<element type="BandMember">
<name>Joe Bloggs</name>
<section>Basses</section>
<position>1st</position>
<joined>2004</joined>
<composer>Something</composer>
<musicpiece>Someething</musicpiece>
<bandmoment>Something</bandmoment>
<notes></notes>
</element>
<element type="BandMember">
<name>Some Body</name>
<section>Front Row Cornets</section>
<position>1st</position>
<joined>2003</joined>
<composer>jkjjkh</composer>
<musicpiece>hkjhjkh</musicpiece>
<bandmoment>Test</bandmoment>
<notes>Some notes</notes>
</element>
</elements>
</container>
</containers>
</page>
---------------

--- XSLT ----

<xsl:key name="section-group" match="element"
use="@type='BandMember'"/>

<xsl:template match="/" mode="show">
<xsl:for-each select="element[generate-id() =
generate-id(key('section-group',section) [1])]">
<h1>
<xsl:value-of select="section"/>
</h1>
<xsl:for-each select="key('section-group',section)">
<xsl:value-of select="name"/>
<br/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

----------------

May 10 '06 #1
1 1294
You should use the section in the key as that is what you want to group
on. Then the for-each selecting element in the document context (/)
will not select anything. Last, you need either to remove the mode on
the template or have some other template that applies templates with
the show mode on the document node. A working stylesheet is below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:key name="section-group" match="element" use="section"/>

<xsl:template match="/">
<xsl:for-each select="//element[generate-id() =
generate-id(key('section-group',section) [1])]">
<h1>
<xsl:value-of select="section"/>
</h1>
<xsl:for-each select="key('section-group',section)">
<xsl:value-of select="name"/>
<br/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

May 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tristan Miller | last post by:
Greetings. I have a question involving sorting and grouping output using XSLT. I am trying to produce a publication list from a BibTeX-like XML file: <bibxml:file...
117
by: Peter Olcott | last post by:
www.halting-problem.com
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...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
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. ...
2
by: la.brunning | last post by:
Hello, I am trying to filter a Muenchian grouping I have created. I think I am fairly close, but I am not quite sure where to apply my filter; its been some time since I did any work with XSLT....
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...

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.