[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: grouping headers

Subject: Re: grouping headers
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 24 Aug 2001 20:08:10 +0100
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>&#xA;</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>&#xA;</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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.