Tuesday, 17 February 2015

XSLT to copy an XML with change of values



We have a xml which needs to be transformed using XSLT. But, we have to add two attributes of a tag and place it in other tag.


In below XML compilation tag with column 'Reusable' has values contrib and max_available. We want addition of these two attributes and want it in the attribute postPosition of compilation tag with column "Usable".


Input



<?xml version="1.0" encoding="UTF-8"?>
<answers>
<answer name="compile">
<output>
<compilations>
<compilation column="Usable" contrib="0" max_available="0" postPosition="35000">
</compilation>
<compilation column="Reusable" contrib="100.00" postPosition="100.00" max_available="200">
</compilation>
</compilations>
</output>
</answer>
</answers>


Output :



<?xml version="1.0" encoding="UTF-8"?>
<answers>
<answer name="compile">
<output>
<compilations>
<compilation column="Usable" contrib="0" max_available="0" postPosition="300.00">
</compilation>
<compilation column="Reusable" contrib="100.00" postPosition="100.00" max_available="200">
</compilation>
</compilations>
</output>
</answer>
</answers>

No comments:

Post a Comment