XSLT to find elements whose total is equal to a target value
Summary:
I have an xml in the following format and a target value.
<Items>
<Item>
<name>a</name>
<value>10</value>
</Item>
<Item>
<name>b</name>
<value>15</value>
</Item>
<Item>
<name>c</name>
<value>25</value>
</Item>
</Items>
I need to find all the elements whose value is equal or less than the target value.
case 1: find the elements whose total is equal to the target 25
solution: 10+15=25 is equal to the target 25, then print the two elements and ignore the remaining elements.
<Items>
<Item>
<name>a</name>
<value>10</value>
</Item>
<Item>
<name>b</name>
<value>15</value>
</Item>
</Items>
case 2: if total of all the elements is less than the target 55, then print all the elements