[xsl] Sorting in descending order on the sum of a calculation

Subject: [xsl] Sorting in descending order on the sum of a calculation
From: "delay" <delay@xxxxxxxxx>
Date: Wed, 28 Nov 2001 23:42:02 -0600
I am rather new to xml and this list... I am trying to convert a stats
program I wrote into xml / xsl format and I am having trouble getting one of
the xsl style sheets to work.  I need to sort the result of a sum performed
on an xml attribute in descending order by the total sum retrieved.  I can
sum all of the like fields in a table for display but I am having trouble
getting it to then display in descending order.

Below is my current xml and xsl and the output it generates.

<referer hits="1" page="/"
ref="http://academic.dt.uh.edu/~finch/links/links.htm"; domain="dt.uh.edu"
keywords="no keywords found"/>
  <referer hits="3" page="/" ref="http://www.rice.edu/houston/";
domain="rice.edu" keywords="no keywords found"/>
  <referer hits="2" page="/calculator/converter.html" ref="bookmarks"
domain="" keywords="no keywords found"/>
 <referer hits="3" page="/calculator/converter.html"
domain="lycosasia.com" keywords="   free  currency  converter"/>
  <referer hits="2" page="/cgi-bin/logscribe/makelog.pl"
ref="http://www.tradehere.com/calendar/calendar.html"; domain="tradehere.com"
keywords="no keywords found"/>
 <referer hits="1" page="/cgi-bin/logscribe/makelog.pl" ref="Blocked by
Norton" domain="" keywords="no keywords found"/>

<xsl:stylesheet version="1.0"
 <xsl:template match="/">
  <xsl:for-each select="//referers/referer">
   <xsl:sort select="@page" order="ascending"/>
   <xsl:if test="not(@page=preceding::referer/@page)">
     -- <xsl:value-of select="@page"/><br/>

Current output:
04 -- /
05 -- /calculator/converter.html
03 -- /cgi-bin/logscribe/makelog.pl

What I want the output to look like:

05 -- /calculator/converter.html
04 -- /
03 -- /cgi-bin/logscribe/makelog.pl

I have looked at a lot of examples in the FAQ (which has some great
examples) but I haven't been able to find anything for my particular case. I
tried sorting based on hits or trying to perform a second sort but didn't
have any success. I was wondering if anyone had any ideas as how to
accomplish this or could point me to an example.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread