XSLT for-each loop and nodes with different pattern

dbabyy

New Member
I have the following structure of xml data to transform:\[code\] <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>\[/code\]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:\[code\]<xsl:template match="chapter"> <xsl:for-each select="paragraph"> <xsl:value-of select="."/> </xsl:for-each></xsl:template>\[/code\]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!
 
Back
Top