This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]