I have a major problem finding a way to add a space between two child elements.
<aaa>
I want to add <bbb>a</bbb><ccc>space</ccc> between two words.
</aaa>
I want to add a space between the “a” and “space” words if the ccc element follows the bbb element immediately. Currently I apply template at aaa element level, and then handle bbb and ccc element in separate templates.
I have no idea how to detect this </bbb><ccc> pattern in advance.
Note: I do not know what words will be inside the bbb and ccc elements.
This transformation:
when performed on the provided XML document:
produces the wanted, correct result:
Do note:
The use of the identity rule to copy all nodes.
The overriding of the identity rule with a specific template to carry out the addition of the space character exactly between the specified
<b>and<i>nodes.The match (XPath expression) pattern used to match exactly the wanted
<b>node after which the space is to be inserted.The code reuse of the template rule, both being applied and called by name.