Thank you for supporting the Cloud Customer Connect Community in 2024. It's a gift to work with you!

Look back
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

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

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!