XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Dink LoSubject: How to sum the values
Author: Dink Lo
Date: 31 Aug 2006 12:09 AM
Hi,

I have use XSLT to select some data I want like follows:

<xsl:for-each select="Datalist">
<xsl:value-of select="value"/>
</xsl:for-each>

If the xml is like follows:

<Datalist>
<value>100</value>
</Datalist>
<Datalist>
<value>200</value>
</Datalist>
<Datalist>
<value>300</value>
</Datalist>

The output will be 100200300.

Now I want to compute the sum of the value.
In this case, the sum will be 600.

In fact my case is more complicated.
I have some constraints to select the value and not all of the value will be selected. So plz don't ask me to use sum function.

Does anybody know how to do that?
Any suggestion will be appreciated.

Dink

Posttop
Ivan PedruzziSubject: How to sum the values
Author: Ivan Pedruzzi
Date: 31 Aug 2006 10:29 PM

It is difficult to help if you don't tell us what are those "constraints".

Are you aware that you can count node using a xpah expression including predicates?

For instance sum only value greater then 100

sum(Datalist/value[ number(.) &gt; 100 ])


Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.