Re: [xsl] distinct-values() optimization, sorting by frequency

Subject: Re: [xsl] distinct-values() optimization, sorting by frequency
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Fri, 8 Feb 2008 14:41:03 +0000
On 08/02/2008, James Cummings <cummings.james@xxxxxxxxx> wrote:

instead of:

>  <xsl:variable name="distinct-persNames"
> select="distinct-values($norm-persNames)"/>

and


>     <xsl:for-each select="$distinct-persNames">
>       <xsl:sort select="count($persNames[normalize-space(lower-case(.))
>         = .])"/>
> <!-- I think it is this sort statement which slows things down, since
> I have to repeat it twice. -->
>       <xsl:variable name="current-name" select="."/>
>       <xsl:variable name="count-distinct-current-name"
>         select="count($persNames[normalize-space(lower-case(.))
>         = $current-name])"/>
>       <item><xsl:value-of select="concat($count-distinct-current-name,
>           '  --  ', $current-name)"/> </item>
>     </xsl:for-each>
>   </list>

do:

<xsl:for-each-group select="$norm-persNames"  group-by=".">
  <xsl:sort select="count(current-group())" data-type="number"
order="descending"/>
  <item>
    <xsl:value-of select="concat($current-grouping-key(),
           '  --  ', count(current-group()))"/>
...


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread