# xsl numeric calculations-NP

 Subject: xsl numeric calculations-NP From: "NILESH PATEL" Date: Fri, 02 Aug 2002 07:19:54 +0000

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.

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

### PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!