Starting from an exemplary, ungainly formatted XML structure:
<list>
<topic>
<title>
Paragraph 1
</title>
</topic>
<topic>
<main>
Content 1
</main>
</topic>
<topic>
<main>
Content 2
</main>
</topic>
<!-- ... -->
<topic>
<main>
Content n
</main>
</topic>
<topic>
<title>
Paragraph 2
</title>
</topic>
<topic>
<main>
Content 1
</main>
</topic>
<!-- ... -->
<topic>
<main>
Content n
</main>
</topic>
</list>
The contents of "title" and "main" are merely placeholders. The content of "title" is different in every node. The content of "main" may or may not vary. The number of "main" elements is indefinite.
The goal is to summarize the topic / main elements following a topic / title element as follows:
<list>
<paragraph name="1">
<item>Content 1</item>
<item>Content 2</item>
<item>Content n</item>
</paragraph>
<paragraph name="2">
<item>Content 1</item>
<item>Content n</item>
</paragraph>
</list>
Boundary condition is the restriction to version 1 of xslt and xpath.
This question has been asked in similar form before. I did not find a satisfactory answer.
Basically, you're looking for an XSLT 1.0 implementation of
group-starting-with
. This can be done as following:XSLT 1.0