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

Sorting in descending order on the sum of a calculatio

Subject: Sorting in descending order on the sum of a calculation
From: "delay" <delay@xxxxxxxxx>
Date: Wed, 28 Nov 2001 23:42:02 -0600
html calculator
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.

<referers>
<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"
ref="http://sg.lycosasia.com/?query=++%2Bfree+%2Bcurrency+%2Bconverter"
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"/>
 </referers>
__________________________________________________________________

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <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="format-number(sum(//referers//referer[@page=current()/@page]/@hits),
'####00')"/>
     -- <xsl:value-of select="@page"/><br/>
      </xsl:if>
   </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

___________________________________________________________________
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.

Thanks,
-Delay


 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.