xsl-list
[Top] [All Lists]

Re: [xsl] Keeping a running total? (Redo)

2006-07-11 13:16:16
On 7/11/06, Steve <subsume(_at_)gmail(_dot_)com> wrote:
I will cross that bridge when I get to it. I'm having a hard enough
time getting help for the first problem.

When I solve how to keep a running total, it will be easy to add
whatever is left over to the next quota.

Then here's the running-total part:

This xslt transformation:

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:f="http://fxsl.sf.net/";
 exclude-result-prefixes="f"

 <xsl:import href="../f/func-scanl.xsl"/>
 <xsl:import href="../f/func-Operators.xsl"/>

 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/">
    <xsl:for-each select="f:scanl1(f:add(), /*/*/@capacity)">
     <xsl:value-of select="concat(., ', ')"/>
    </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

when applied against the provided source xml document:

<xml>
<factory x="A" capacity = "3" />
<factory x="B" capacity= "5" />
 <factory x="C" capacity = "3" />
 <factory x="D" capacity = "2" />
 <factory x="E" capacity = "2" />
 ...etc...
</xml>

produces the wanted result (the list of running totals):

3, 8, 11, 13, 15,

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--