Hi Todd,
You could try something like...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="top5-ids">
<xsl:text>|</xsl:text>
<xsl:for-each select="items/item/value">
<xsl:sort select="." data-type="number" order="descending"/>
<xsl:if test="position() < 6">
<xsl:value-of select="generate-id()"/>
<xsl:text>|</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:text>Sum of top 5 is: </xsl:text>
<xsl:value-of
select="sum(items/item/value[contains($top5-ids,concat('|',generate-id()
,'|'))])"/>
<xsl:text> Sum of rest is: </xsl:text>
<xsl:value-of
select="sum(items/item/value[not(contains($top5-ids,concat('|',generate-
id(),'|')))])"/>
</xsl:template>
</xsl:stylesheet>
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Todd Binder
Sent: 27 December 2002 21:18
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] summing 5 largest nodes
I am attempting to sum the certain groupings of nodes, based on the max
and
min values contained in the nodes.
For example, if there are 20 node elements, sum the 5 largest and the
other
15 values (ending with 2 values)
using POSITION(), I can determine what the 5 largest (or 15 other values
are), but I can't seem to determine how to sum these values.
my XML looks like
<items>
<item>
<value>6</value>
</item>
<item>
<value>3</value>
</item>
<item>
<value>7</value>
</item>
</items>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list