Using XSLT 1.0, I need to group each node between processing instructions <?start?> and <?end?>. The nodes outside of this pair should be unchanged at the output.
First, I need to find a way how to select only the nodes that are between each start - end pair. Suppose we have an example input XML:
<root>
abc
<?start?>
def<Highlighted bold="yes">
<Highlighted italic="yes">ghi</Highlighted>
</Highlighted>jkl
<?pi?>
<table>
<Caption>stu</Caption>
</table>vw
<?end?>
xy
<?start?>
abc <Caption>def</Caption> ghi
<?end?>
jkl
</root>
Furthermore, I need to have nodes OUTSIDE the "start - end" intersections at the output as well. This means that at the output: a) nodes at the intersection of start - end PI will be in the group element b) any node outside the intersection will be printed unchanged. Note that the input document may also have no start - end processing instruction pair.
For example, from the given input, the output should be as follows:
<root>
abc
<group>
def<Highlighted bold="yes">
<Highlighted italic="yes">ghi</Highlighted>
</Highlighted>jkl
<?pi?>
<table>
<Caption>stu</Caption>
</table>vw
</group>
xy
<group>
abc <Caption>def</Caption> ghi
</group>
jkl
<root>
A part of this question has already been answered in Finding all XML nodes between each two processing instructions. But I struggle with printing out nodes outside of the group element without duplicating any node.