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

Re: Sum() function

Subject: Re: Sum() function
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Tue, 22 Feb 2000 20:21:43 -0800
callum elliott
I think you must just have ill-formed XML. Your
stylesheet looks ok.

Given:

<report>
  <tranxs>
    <tranx cccf="N" amt="1"/>
    <tranx cccf="Y" amt="2"/>
    <tranx cccf="N" amt="3"/>
    <tranx cccf="Y" amt="4"/>
  </tranxs>
 </report>

and:

<foo xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:for-each select="report">
    <xsl:value-of select="sum(tranxs/tranx[@cccf = 'N']/@amt)"/>
  </xsl:for-each>
</foo>

I get:

<foo>4</foo>

which is the sum of 1 and 3.
_________________________________________________________
Steve Muench, Consulting Product Manager & XML Evangelist
Business Components for Java Development Team

----- Original Message ----- 
From: "Callum Elliott" <c.j.elliott-96@xxxxxxxxxxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxx>
Sent: Tuesday, February 22, 2000 7:49 PM
Subject: Sum() function


| Hi there,
| 
| I'm trying to sum report totals, but I only want to sum certain attributes.
| For example
| 
| My.xml
| 
| <report>
| <tranxs>
| <tranx cccf="N" amt="200">
| </tranx>
| </report>
| 
| My.xsl
| 
| <xsl:for-each select="report">
| ...
| <xsl:value-of select="sum(tranxs/tranx[@cccf = 'N']/@amt)"/>
| 
| I know the above line is wrong, but I don't know how to fix it.  I want it
| to sum depending on the cccf attribute value.
| 
| Thanks in advance,
| 
| Callum Elliott
| 
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 


 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.