Subject: Re: [xsl] grouping headers From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 24 Aug 2001 20:08:10 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] grouping headers, Sullivan, Dan | Thread | [xsl] selecting parents of node-set, Wilcox, Paul |
Re: [xsl] XPath for selecting all t, Wendell Piez | Date | RE: [xsl] xpath expression in <xsl:, Sullivan, Dan |
Month |