I have a source xml, that looks like below:
<root>
<CompoundPredicate booleanOperator="surrogate">
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
<False />
</CompoundPredicate>
<CompoundPredicate booleanOperator="surrogate">
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
<SimplePredicate field="AGE" operator="lessOrEqual" value="40" />
<False />
</CompoundPredicate>
</root>
I want to perform a transformation in such way, that 1). if there is only 'False' element after the inner 'CompoundPredicate' element, then delete the outer 'CompoundPredicate' element and the element which appears after the inner 'CompoundPredicate' element. For example,
<CompoundPredicate booleanOperator="surrogate">
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
<False />
</CompoundPredicate>
becomes
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
2) if there are other elements after the inner 'CompoundPredicate' element other than 'False', then only delete 'False' element which appears after the inner 'CompoundPredicate' element. For example,
<CompoundPredicate booleanOperator="surrogate">
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
<SimplePredicate field="AGE" operator="lessOrEqual" value="40" />
<False />
</CompoundPredicate>
becomes
<CompoundPredicate booleanOperator="surrogate">
<CompoundPredicate booleanOperator="and">
<True />
<SimplePredicate field="MODELYEAR" operator="lessOrEqual" value="1999" />
</CompoundPredicate>
<SimplePredicate field="AGE" operator="lessOrEqual" value="40" />
</CompoundPredicate>
For this problem, I don`t even know how to start. I would really appreciate your help. Thanks a lot.
Aucun commentaire:
Enregistrer un commentaire