This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
grouping content
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] grouping content
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Fri, 6 Apr 2001 09:57:41 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, Gavinm
Following is provided based two level grouping method for your group
problem. Test using ie5 and msxml3.
<?xml version="1.0" encoding="big5" ?>
- <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />
<xsl:key name="Area" match="Location" use="@Area" />
<xsl:key name="Value" match="Location" use="concat(@Area,' ',@Value)" />
<xsl:variable name="source" select="/docs/Location" />
- <xsl:template match="/">
- <xsl:apply-templates
select="//Location[generate-id(.)=generate-id(key('Area',@Area)[1])]"
mode="first">
<xsl:sort select="@Area" />
</xsl:apply-templates>
</xsl:template>
- <xsl:template match="Location" mode="first">
<br />
Location
<xsl:value-of select="@Area" />
<br />
- <xsl:apply-templates select="key('Area',@Area)[generate-id(.)
=generate-id(key('Value',concat(@Area,' ',@Value))[1])]" mode="second">
<xsl:sort select="@Value" />
</xsl:apply-templates>
</xsl:template>
- <xsl:template match="Location" mode="second">
<xsl:value-of select="key('Value',concat(@Area,' ',@Value))/@Value" />
<br />
</xsl:template>
</xsl:stylesheet>
hope it will help,
Sun-fu Yang
sfyang@unisvr.net.tw
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list