| Author |
XSLT - computing numeric values
|
Romain Thuaudet
Greenhorn
Joined: Jan 06, 2012
Posts: 1
|
|
Hello guys,
I am totally new to XSLT and I need to use it to compute interest flows from a XML document.
Here is the relevant part of the XML document:
What I want to do is to get the sum of the quantities notionalAmount*coupon present in each interestPaymentPeriod node. For instance here, the result expected would be 1.71784*10000+1.86914*10000+1.79553*10000= 53825.1
The tricky part is that I don't know how many interestPaymentPeriod nodes I am going to have. There can be 1 node or 22 of them.
So far I tried to do this with a for-each loop and I have also tried to emulate a while loop with no success.
Here is my XSLT formula with the for-each loop:
It does not work, I dont retrieve any values. Could someone please take a look at it ? I am really new to XSLT, I am just an intern who has to take care of this and I am sorry if there are silly mistakes in my code.
Sorry for my potential english mistakes!
Thanks a lot for your help!
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 2686
|
|
Hi Romain. Welcome to The Ranch!
"Variables" in XSLT are a bit misleadingly named. They aren't, really. Once assigned they can't be reassigned. Therefore, you can't use them in a procedural way like you're trying to do here.
My XSLT is very rusty, but I'd probably try a recursive method for this. Here's an example. Be warned, though, this is off the top of my head and hasn't been tested!
|
 |
 |
|
|
subject: XSLT - computing numeric values
|
|
|