This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: grouping headers
- To: "Sullivan, Dan" <dsullivan at develop dot com>
- Subject: Re: [xsl] grouping headers
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 24 Aug 2001 20:08:10 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <94FD4438D783D74EA86DC692E776C12774CC34@la-infoserver.develop.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Dan,
> I tried your suggestion of using xsl:key instead of my (fixed up)
> rather plodding solution. I found no significant difference in the
> performance of the two.
That surprises me. Would you mind sharing the stylesheets that you
tried? I tried testing with MSXML (using -t to get timing information)
and there was a substantial difference between the following two
templates:
--- using keys ---
<xsl:key name="people" match="person" use="city" />
<xsl:template match="/">
<xsl:for-each
select="people/person[count(.|key('people', city)[1]) = 1]">
<xsl:value-of select="city" />
<xsl:for-each select="key('people', city)">
<xsl:value-of select="name" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
---
--- using preceding-sibling ---
<xsl:template match="/">
<xsl:for-each
select="people/person[not(preceding-sibling::person/city = city)]">
<xsl:value-of select="city" />
<xsl:for-each
select="/people/person[city = current()/city]">
<xsl:value-of select="name" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
---
With 1000 person elements, in MSXML the execution time of the key
version took about 100ms whereas the preceding-sibling version took
about 2300ms.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list