This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Problem with grouping
- From: "Bjorn Boxstart" <boxstart at dcdds dot nl>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 13 Mar 2002 09:21:22 +0100
- Subject: [xsl] Problem with grouping
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello all,
I have a problem with the use of the meunchian method for grouping.
The problem is that, within the items that I want to group can belong
to more than one group and I also want them to be listed in all valid
groups. The stylesheet that I have now lists each item in only one
group.
The XML structure of my items is:
<inks>
<ink>
<type>type 1</type>
<applicability>
<item model="epson stylus 870"/>
<item model="epson stylus 880"/>
</applicability>
</ink>
<ink>
<type>type 2</type>
<applicability>
<item model="epson stylus 850"/>
<item model="epson stylus 880"/>
</applicability>
</ink>
<ink>
<type>type 3</type>
<applicability>
<item model="HP 720C"/>
</applicability>
</ink>
</inks>
The result should be something like:
Epson stylus 850
- type 2
Epson stylus 870
- type 1
- type 2
Epson stylus 880
- type 2
HP 720C
- type 3
I tried to do this with the muenchian method, but when a <ink> element
had applicablility settings for two categories, it was only listed in
one.
Please find a part of the XSLT code below.
<xsl:key name="applicability" match="ink"
use="applicability/item/@model" />
<xsl:template match="inks">
<xsl:for-each select="ink[generate-id()
=generate-id(key('applicability', applicability/item/@model)[1])]">
<xsl:sort select="applicability/item/@model" />
<h1><xsl:value-of select="applicability/item/@model" /></h1>
<xsl:for-each select="key('applicability',
applicability/item/@model)">
<xsl:sort select="type" />
<div><xsl:apply-templates select="type"/></div>
</xsl:for-each>
</xsl:for-each> -->
</xsl:template>
If anybody has a suggestion, please don't hesitate to answer this
email ;-)
Regards,
Bjorn
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list