I have an XML file structured like so:
<root>
<a>...</a>
<b>...</b>
<a>...</a>
<a>...</a>
<comment>...</comment>
<a>...</a>
<b>...</b>
<comment>...</comment>
<a>...</a>
<b>...</b>
</root>
I would like to use XSLT to transform it so that each sequence of as and bs is gathered into a single <div>, like so:
<root>
<div>
<a>...</a>
<b>...</b>
<a>...</a>
<a>...</a>
</div>
<comment>...</comment>
<div>
<a>...</a>
<b>...</b>
</div>
<comment>...</comment>
<div>
<a>...</a>
<b>...</b>
</div>
</root>
My first attempt involved putting a <div>...</div> inside the root, and then wrapping each comment in </div>...<div> (note the reversal of the tags), but that's not allowed in XSLT. How can I do this?
The following question is related to mine, but it involves counting a fixed number of as and bs, whereas I want to count as and bs until I hit a comment: