[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Multiple Grouping & Muenchian Method

Subject: RE: Multiple Grouping & Muenchian Method
From: "Jacoby, Peter R." <PJACOBY@xxxxxxxxxxxx>
Date: Fri, 21 Jul 2006 15:17:17 -0400
muenchian method parameter
>>Is it possible to have a group within a group.

Hi, Steve,

You were really close in your code.  The concept that you were missing is to
define one xsl:key with two parameters using the concat function.

If you change your key declaration to be
<xsl:key name="byDateAndCountry" match="entry"
use="concat(parent::group/parent::date/text(), country)" />
or more succinctly:
<xsl:key name="byDateAndCountry" match="entry" use="concat(../../text(),
country)" />

You can then call one key indexed by an entry's date as well as country.

A full stylesheet is below.  Please let us know if you have any other
This all becomes a lot easier in 2.0 with xsl:for-each-group.  Hopefully
will post the 2.0 solution so we can see how much simpler it is.


<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"

<xsl:key name="byDateAndCountry" match="entry" use="concat(../../text(),
country)" />

<xsl:template match="/">
	<table border="1">
		<xsl:apply-templates select="report/table/date"/>

<xsl:template match="date">
			<xsl:value-of select="normalize-space(text())" />

	<xsl:for-each select="group/entry[generate-id() =
generate-id(key('byDateAndCountry', concat(../../text(), country))[1])]">
				<xsl:value-of select="country" />
		<xsl:apply-templates select="key('byDateAndCountry',
concat(../../text(), country))" />

<xsl:template match="entry">
			<xsl:value-of select="../@type" />
			<xsl:value-of select="name" />
			<xsl:value-of select="id" />


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.