I got two possible XML files:
<orders>
<order id="1">
<code value="001-AAA"/>
<altCode value="002-BBB"/>
</order>
</orders>
And:
<orders>
<order id="2">
<code value="001-AAA"/>
<altCode value=""/>
</order>
</orders>
I would like the <code>tag's value attribute to be replaced by the <altCode>tag's value attribute, unless the second value is empty. In that case I would like the XML te remain unchanged. The <altCode>tag doesn't need to be changed.
So the resulting two XML files should look like this:
<orders>
<order id="1">
<code value="002-BBB"/>
<altCode value="002-BBB"/>
</order>
</orders>
And:
<orders>
<order id="2">
<code value="001-AAA"/>
<altCode value=""/>
</order>
</orders>
Note: The actual files I like to convert are a lot more complex. So I prefer to copy the template and change the attribute after with a when-statement.
Any help is very much appreciated.