I’m having troble with a XML I need to transform woth xslt.
Here is my XML
<Groups>
<term>
<Tag1>My system1</Tag1>
<Tag2>yes</Tag2>
<Tag3>new york</Tag3>
</term>
<term>
<Tag1/>
<Tag2>no</Tag2>
<Tag3>chicago</Tag3>
</term>
<term>
<Tag1>My system2</Tag1>
<Tag2>ok</Tag2>
<Tag3>paris</Tag3>
</term>
<term>
<Tag1/>
<Tag2>help</Tag2>
<Tag3>london</Tag3>
</term>
<term>
<Tag1/>
<Tag2>cancel</Tag2>
<Tag3>rome</Tag3>
</term>
</Groups>
And here is my desired output.
<Groups>
<term>
<Tag1>My system1</Tag1>
<Tag2>yes</Tag2>
<Tag3>new york</Tag3>
</term>
<term>
<Tag1>My system1</Tag1>
<Tag2>no</Tag2>
<Tag3>chicago</Tag3>
</term>
<term>
<Tag1>My system2</Tag1>
<Tag2>ok</Tag2>
<Tag3>paris</Tag3>
</term>
<term>
<Tag1>My system2</Tag1>
<Tag2>help</Tag2>
<Tag3>london</Tag3>
</term>
<term>
<Tag1>My system2</Tag1>
<Tag2>cancel</Tag2>
<Tag3>rome</Tag3>
</term>
</Groups>
All the xslt needs to do is to fill empty tags with value from the previous non-empty tags.
I tried using variable but apparently they do not work like variable in imperative languages.
Any advice on how to do this ?
Thanks
This simple stylesheet should do it: