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

Re: Re: patial sums

Subject: Re: Re: patial sums
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 12 Apr 2002 00:50:23 -0700 (PDT)
patial
Matt Gushee <mgushee at havenrock dot com> wrote:

> > I have an XML like this:
> > 
> > <?xml version='1.0' ?>
> > <?xml-stylesheet type='text/xsl' href='raport.xsl'?><data>
> > <row Cod='212' Denumire='VINZARI CATRE ALTE UNITATI' 
> > Document='FACTURA'
> > Numar='12358' Data='2000-10-19' Furnizor='32802' Comanda='X'
> > Valoare='757900.0'/>
> > ....
> > </data>
> > 
> > and in the following XSL I want to display partial sums on the 
> attribute
> > "Valoare" after each grouping. I am new in XML and I tried 
> everything I knew
> > but it doesn't work. It is possible? and if yes, how?
> 
> Boy, that is some dangerous-looking XSLT you've got there, sir ;-)
> 
> But the answer to your question is, yes. Here's a drastically 
> simplified example of one technique that will work:
> 
>     <xsl:for-each select="row">
>       <xsl:value-of select="sum(@Valoare|preceding-
> sibling::*/@Valoare)"/>
>     </xsl:for-each>
> 
> In other words, each time a row is processed, output the sum of the 
> current row's Valoare attribute and the Valoare attributes of all 
> previous rows. I think that's what you need, isn't it?


This has an O(N^2) complexity because the same sums are re-calculated
all over again and again.

For a linear solution for obtaining incremental results over a list
(e.g. running totals, etc.) do have a look at the functions scanl() and
scanl1() from the FXSL functional programming library. they are located
in the file scanl.xsl


Hope this helped.

Cheers,
Dimitre Novatchev.



__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

 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.