|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: grouping headers
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








