This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

xsl numeric calculations-NP




Dear Friends,

I am trying to achoeve simple calcuateion from xsl. I do not know the way out of this. Please help. Here is the code.

XML:
======
<Shopping>
<fruits>
<apple quantity="10" unit_price="1"></apple>
<orange quantity="20" unit_price="5"></orange>
<banana quantity="30" unit_price="5"></banana>
<grapes quantity="40" unit_price="5"></grapes>
</fruits>
<vegs>
<onion quantity="10" unit_price="5"></onion>
<carrot quantity="5" unit_price="10"></carrot>
<chiili quantity="20" unit_price="5"></chilli>
<tomato quantity="10" unit_price="5"></tomato>
<potato quantity="20" unit_price="5"></potato>
</vegs>
</shopping>

XSL:
======
//suggest xsl template here, because I tried using sum() and numbers and so on but could not work the way around it. I could do individual multiplication using <xsl:for-each select="//fruits/*">. but did not achieve results.SO I BEG TO THE COMMUNITY, PLEASE HELP ME NOW.


Required Result:
=================
FRUITS: (10*1) + (20*5) + (30*5) + (40*5) = 460
VEGS : (10*5) + (5*10) + (20*5) + (10*5) + (20*5) = 350



Basically, I want to multiply "quantity" and "unit_price" first then add the multiplication-result.May be using javascript or xsl built in functions, please suggest.

Thanks very much in advance.

Nilesh Patel

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]