[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: summing up incrementally

Subject: Re: summing up incrementally
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 19 Dec 2003 00:23:34 GMT
Re:  summing up incrementally
> So what I need to do is add all the previous months of December to the
> current month of December:

that would just be <xsl:value-of select="sum(preceding-sibling::year/month[@month='December']/@percentage-increase)"/>

But it sounds like you want a product, not a sum????

> The first year (1937) increases only 103 percent from the previous year.
> 
> The next year (1938)shows an increase of 102 percent from 1937. But
> cumalitively it shows an increase of 105 percent: 103 + 102 = 105.
> 
> The next year (1939)  shows an increae of 108 percent. Cumulatively,
> this is 113: 103 + 102 + 108 = 113.

cumulative interest isn't additive
The increase over three years is 1.03 * 1.02 * 1.08 =~ 1.135 or 13.5%
so you will need a recursive template as xpath2 doesn't have a product
built in (or you could use saxon7's implementation of xpath 2 draft,
which does)

David


-- 
http://www.dcarlisle.demon.co.uk/matthew

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.