i have xml:
<people>
<man age="20" />
<man age="40" />
<man age="30" />
<man age="80" />
<people>
with xsl i am trying to output:
first age:20
first and second age (combined): 60
first second and third age(combined) :110
first second third and fouth age(combined) :190
i know how to select the ages, but how do i add them together and write it out?
Also note that the <man> elements can be more than just 4.
Ok, I just read that you just need the numbers, so the following stripped xslt
produces following on your sample input-
The template (Original one with labels and stuff):
produces following output for your input xml:
I have added comments inside, let me know if you need further help.
It basically uses two recursive templates one each for the ‘labels’ and other for the addition.
And, Your sample output should read 90 and 170 instead of 110 and 190 or your sample input should say age=50 instead of age=30