[xsl] Trying to pull of a double Muenchian

Subject: [xsl] Trying to pull of a double Muenchian
From: Verakso <verakso@xxxxxxxxx>
Date: Tue, 28 Feb 2006 15:03:56 +0100
I have found various suggestions on this list, and links to more
explanatory pages describing the Muenchian technique to sort or group
xml data.

However, I am trying to do a kind of a double Muenchian, which is to
group xml data i two levels. but there must be something i am missing,
because it is not working as I expected.

The xml is the kind of standard data format:
   <item name="1">data 1</item>
   <item name="2">data 2</item>
   <item name="3">data 3</item>
   <item name="1">data 1</item>
   <item name="2">data 2</item>
   <item name="3">data 3</item>

My real xslt look like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
	<!-- V A R I A B L E S -->
	<xsl:key name="suplier" match="/csv_data_records/record" use="item[2]"/>
	<xsl:key name="product" match="/csv_data_records/record" use="item[4]"/>
	<xsl:template match="/">
	<xsl:template match="csv_data_records">
		<xsl:for-each select="record[count(. | key('suplier', item[2])[1])=1]">
				<xsl:attribute name="name"><xsl:value-of
				<xsl:attribute name="value"><xsl:value-of
				<xsl:for-each select="key('suplier', item[2])">
						<xsl:attribute name="group"><xsl:value-of
						<xsl:for-each select="key('product', item[4])">
									<xsl:value-of select="item[1]"/>
									<xsl:value-of select="item[6]"/>
									<xsl:value-of select="item[7]"/>

It seems that I am not getting the second grouping on the items right.
They are grouped all right, but they are repeated x times the node

What have I missed out, or what am I doing wrong here.


Current Thread