Apologies if this a seen as a “gimme the codez” type question but my xpath skills were not up to scratch on this. It is in my opinion generic enough to be of interest for more people
Given this multilingual XML file below. We need to substitue the blank Dutch entries with their English sibling element.
Input:
<Testing>
<T4 t="dutch"></T4>
<T4 t="english">Testing Software</T4>
<T4 t="french"/>
<T4 t="italian"/>
</Testing>
<P>
<T1 t="dutch"></T1>
<T1 t="english">Testing Phase. </T1>
<T1 t="french"></T1>
<T1 t="italian"></T1>
</P>
output:
<Testing>
<T4 t="dutch">
<trans>Testing Software</trans>
</T4>
<T4 t="english">Testing Software</T4>
<T4 t="french"/>
<T4 t="italian"/>
</Testing>
<P>
<T1 t="dutch"><trans>Testing Phase.</trans></T1>
<T1 t="english">Testing Phase. </T1>
<T1 t="french"></T1>
<T1 t="italian"></T1>
</P>
This should work…
XML Input (wrapped in
inputto be well-formed)XSLT 1.0
Output