ppeter
11-08-2004, 12:37 PM
Hi folks,
This will probably sound very very newbie, but I am an XSLT newb...
Say I have my XML file like so:
<myxml>
<content>
<heading>Heading 1</heading>
<subheading>Heading 2</subheading>
<paragraph>This is some content. Foo bar, foo bar, foo bar...</paragraph>
<paragraph>Wooo another paragraph! This is getting repetitive...</paragraph>
<heading>Another Heading 1</heading>
<paragraph>YEAH!!!!!!!!!! Oh, right...</paragraph>
</content>
</myxml>
and I have an XSL template something like this....
<xsl:for-each select="heading">
<h1><xsl:value-of select="heading"></h1>
</xsl:for-each>
<xsl:for-each select="subheading">
<h2><xsl:value-of select="subheading"></h2>
</xsl:for-each>
<xsl:for-each select="paragraph">
<p><xsl:value-of select="paragraph"></p>
</xsl:for-each>
Now, I realise that will chuck out 2 <h1> tags followed by one <h2> tag and then my 3 <p> tags.... but how do I get them 'chucked out' in the order in which they appear in the XML file??
Hope that makes sense... sorry for the poor example.
This will probably sound very very newbie, but I am an XSLT newb...
Say I have my XML file like so:
<myxml>
<content>
<heading>Heading 1</heading>
<subheading>Heading 2</subheading>
<paragraph>This is some content. Foo bar, foo bar, foo bar...</paragraph>
<paragraph>Wooo another paragraph! This is getting repetitive...</paragraph>
<heading>Another Heading 1</heading>
<paragraph>YEAH!!!!!!!!!! Oh, right...</paragraph>
</content>
</myxml>
and I have an XSL template something like this....
<xsl:for-each select="heading">
<h1><xsl:value-of select="heading"></h1>
</xsl:for-each>
<xsl:for-each select="subheading">
<h2><xsl:value-of select="subheading"></h2>
</xsl:for-each>
<xsl:for-each select="paragraph">
<p><xsl:value-of select="paragraph"></p>
</xsl:for-each>
Now, I realise that will chuck out 2 <h1> tags followed by one <h2> tag and then my 3 <p> tags.... but how do I get them 'chucked out' in the order in which they appear in the XML file??
Hope that makes sense... sorry for the poor example.