Connecting Tech Pros Worldwide Help | Site Map

[XSLT Recursive Template Help]: Template to ADD and MULTIPLY node values recursively.

Newbie
 
Join Date: Oct 2006
Posts: 1
#1: Oct 9 '06
Hi everyone,

I have come by a challenge....

I have the following XML file, which represents expressions with "+" and "*" artihmentic operands:

<m value="10">
<i value="5"/>
<m value="10">
<i value="2"/>
<i value="2"/>
<i value="2"/>
</m>
</m>

This represents the following expression:
10 * (5 + (10 * (2 + 2 + 2)))

I want to compute the expression's value (for the given example, the result should be 650). Please note that "I" nodes do not have children nodes and that "m" nodes can either have "i"/"m" children nodes....

Can anyone help me achieve this through a single recursive template?

Many thanks....

Nuno Viana
Reply