[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: patial sums
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
|
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
|