I need some help on the xslt that I’m writing. Below is my source xml.
<document>
<content1></content1>
<content2></content2>
<Br/>
<content3></content3>
<content4></content4>
<Br/>
<content5></content5>
<content6></content6>
</document>
Here’s the structure of the output I intend to create:
<document>
<p>
<content1></content1>
<content2></content2>
</p>
<p>
<content3></content3>
<content4></content4>
</p>
<p>
<content5></content5>
<content6></content6>
</p>
</document>
My question is, how do I group the contents and wrap it in a “<p>” tag whenever I see the “<Br>” tag?
Thanks!
Using the Muenchian Method to group children of
documentby their first precedingBr:Explanation: First, items are grouped in a
keybased on their first precedingBrelement:The Identity Transform is used to copy most nodes through unchanged:
We then match all children of
documentthat are the first such item for theirkey:…and use that as the point at which to copy all items grouped by that
key: