I have the following structure of xml data to transform:
<chapter>
<title>Text</title>
<subtitle>Text</subtitle>
<paragraph>Text</paragraph>
<paragraph>Text</paragraph>
<subtitle>Text</subtitle>
<paragraph>Text</paragraph>
<other>Text</other>
</chapter>
<chapter>
<title>Text</title>
<paragraph>Text</paragraph>
<paragraph>Text</paragraph>
<paragraph>Text</paragraph>
<other>Text</other>
</chapter>
<chapter>
<title>Text</title>
<paragraph>Text</paragraph>
<subtitle>Text</subtitle>
<paragraph>Text</paragraph>
<paragraph>Text</paragraph>
<other>Text</other>
</chapter>
As you can see, the subtitles in the different chapters have no permanent pattern. In the output, I need to set the subtitles on the same place like the are in the xml. For the paragraph tags, I use a for-each loop. Like this:
<xsl:template match="chapter">
<xsl:for-each select="paragraph">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
And now, I need to set the subtitles above, between or among the paragraphs in the order they are in the xml. How can I do this? Please help!