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

Subject: RE: [xsl] Sorting in descending order on the sum of a calculation
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 29 Nov 2001 09:16:41 -0000
> 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.

Tackle this as a two phase transformation, phase one to do the summation and
phase two to do the sorting. Put  the intermediate results in a result tree
fragment, and process it for phase two using the xx:node-set() extension
function that comes with your chosen processor.

<xsl:variable name="phase1out">
  <xsl:apply-templates select="/" mode="phase1"/>
</xsl:variable>

<xsl:template match="/">
  <xsl:apply-templates select="xx:node-set($phase1out)" mode="phase2"/>
</xsl:template>

Mike Kay


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


Current Thread