The watered-down version of the problem I\'m having is this. For an XML file like:
Here is an XSLT 2.0 solution that uses xsl:for-each-group with group-adjacent:
group-adjacent
Output:
Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9 Item 10 Item 11 Item 12 Item 13 Item 14 Item 15 Item 16 Item 17 Item 18