|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using sum to Produce a total from combined documen
Hi Eric,
> I need to get a total using a calculation.
Then you need a recursive template that steps through the nodes for
which you want to calculate a subtotal, keeping track of the total as
it goes:
<xsl:template name="total">
<xsl:param name="quotes" select="equity-quote" />
<xsl:param name="total" select="0" />
<xsl:choose>
<xsl:when test="$quotes">
<xsl:variable name="quote" select="$quotes[1]" />
<xsl:variable name="subtotal"
select="$config/stocks/stock[@symbol=$quote/@symbol]/@shares *
$quote/last-sale-price" />
<xsl:call-template name="total">
<xsl:with-param name="quotes"
select="$quotes[position() > 1]" />
<xsl:with-param name="total"
select="$total + $subtotal" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$total" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
To insert the total, just call the template:
<xsl:call-template name="total" />
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








