468,257 Members | 1,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Muenchian problem


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:



---- XML ----
<?xml version="1.0" encoding="utf-8"?>
<pagename>The Band</pagename>
<menuname>The Band</menuname>
<container name="content">
<element type="BandMember">
<name>Luke Skywalker</name>
<section>Front Row Cornets</section>
<musicpiece>Lazy Trumpeter</musicpiece>
<element type="BandMember">
<name>Joe Bloggs</name>
<element type="BandMember">
<name>Some Body</name>
<section>Front Row Cornets</section>
<notes>Some notes</notes>

--- XSLT ----

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

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


May 10 '06 #1
1 1137
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"

<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])]">
<xsl:value-of select="section"/>
<xsl:for-each select="key('section-group',section)">
<xsl:value-of select="name"/>

George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

May 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tristan Miller | last post: by
117 posts views Thread by Peter Olcott | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
1 post views Thread by aleksander.hansen | last post: by
2 posts views Thread by la.brunning | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.