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

result = node1 * node2 and then get total of all the

Subject: result = node1 * node2 and then get total of all the result from whole document at the end
From: "Khalid Ali" <k_ali@xxxxxxxxxxxxxxx>
Date: Tue, 1 Jan 2002 07:26:44 -0700
khalid ali
Hello everybody,I am new to this forum and new to xslt as well.I have been
stuck with this problem for several days.
what I want to do is,to go through an xml file multiply rate with value at
each level and print the product.
Then at the end of the document I need to add all of the products of
multiplication and print a grand total.
In a structured programming language it may look like this.
double rate=0.0;
int quantity = 0;
double total= 0.0;
double grandtotal =0.0;
for(int x=0;x<xmldoc.length;x++){
    if(element.name=="rate"){
        rate = (double)elementRate.value
    }else if(element.name=="quantity"){
        quantity = (double)elementQuantity.value;
    }
    total= rate * quantity;
    //at aevery cycle I would like to print the total i.e. value
    //then I have to add this value to a agrand total variable.
    grandtotal +=total;
}
I would appreciate if some one can guide me to get this functionality.
below is the segment of an xml file that I am working on.


<adjustments>
 <adjustment>
     <system-id>1</system-id>
        <last-modified />
        <edition>
         <system-id>66</system-id>
          <last-modified>4 December, 2001 11:56</last-modified>
          <edition-name>NW1-Edition</edition-name>
          <start-date>4 December, 2001</start-date>
          <end-date />
        </edition>
        <currency>
         <system-id>2</system-id>
          <last-modified>3 December, 2001 10:01</last-modified>
          <description>Dollars</description>
          <code>CAD</code>
        </currency>
        <transaction-type>
         <system-id>1</system-id>
          <last-modified>3 December, 2001 11:14</last-modified>
          <description>Handling Allowance</description>
        </transaction-type>
        <transaction-date>7 December, 2001</transaction-date>
*        <rate>.32</rate>
*        <quantity>22145</quantity>
        <adjustment-taxes />
 </adjustment>
 <adjustment>
     <system-id>1</system-id>
        <last-modified />
        <edition>
         <system-id>66</system-id>
          <last-modified>4 December, 2001 11:56</last-modified>
          <edition-name>NW1-Edition</edition-name>
          <start-date>4 December, 2001</start-date>
          <end-date />
        </edition>
        <currency>
         <system-id>2</system-id>
          <last-modified>3 December, 2001 10:01</last-modified>
          <description>Dollars</description>
          <code>CAD</code>
        </currency>
        <transaction-type>
         <system-id>1</system-id>
          <last-modified>3 December, 2001 11:14</last-modified>
          <description>Handling Allowance</description>
        </transaction-type>
        <transaction-date>7 December, 2001</transaction-date>
*        <rate>.79</rate>
*        <quantity>1425</quantity>
        <adjustment-taxes />
 </adjustment>
</adjustments>

At this point I can go through the document and get the values from all the
rate and quantity nodes and print their product as well.I am having hard
time adding the product of rate and quantity into a variable and then
increment it and print it at the end of document.
Please help me.In the actual document there will be several
adjustment,supply and other nodes who has rate and quantity nodes.I want to
get the result = rate*quantity and print it on the page as well as I want to
calculate a grand total with all the results of the multiplications of rate
and quantity and print it at the end of the document.
Please help.

Khalid


 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.