xslt: sum up just a for of an integer array
So, I have an array of integers. And I want to sum it up. But not the
whole array but just till a position in the array specified by another
variable.
For example. This beeing my array:
<xsl:variable name="myArray" as="xs:int*">
<Item>11</Item>
<Item>22</Item>
<Item>33</Item>
<Item>44</Item>
<Item>55</Item>
<Item>66</Item>
<Item>77</Item>
<Item>88</Item>
</xsl:variable>
And this beeing my position variable:
<xsl:variable name="myPosition" as="xs:int*">3</xsl:variable>
I expect the result 66. (Because: $myArray[1] + $myArray[2] + $myArray[3]
= 11 + 22 + 33 = 66)
Sounds rather simple but I can't find a solution.
I guess, I need the "sum" function and the "for" and "return" expressions.
But I must admit didn't understand any of the examples and instructions I
found corncerning these.
No comments:
Post a Comment