honestrosewater
Programmer
I have a set of sibling item elements. Some of them have a child head element (headed items), and some do not (non-headed items).
I want to use their headedness to group them in the output:
So I want each headed item to generate a list with itself as the first child and every non-headed item between it and the next headed item as the tail (remaining children).
So I want a while loop, but I am not sure how to implement this in XSLT. I am trying various combinations of for-each, choose, and if with no success yet.
Thanks!
P.S. The distance between each successive headed items is unpredictably variable.
Code:
<source>
<item><head/>1</item>
<item>2</item>
<item>3</item>
<item><head/>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<source>
Code:
<output>
<list>
<item>1</item>
<item>2</item>
<item>3</item>
</list>
<list>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
</list>
</output>
So I want a while loop, but I am not sure how to implement this in XSLT. I am trying various combinations of for-each, choose, and if with no success yet.
Thanks!
P.S. The distance between each successive headed items is unpredictably variable.