Click to See Complete Forum and Search --> : XSL Template question


fliptight
09-10-2008, 02:34 PM
New to XML and I am having trouble googling for how to do this... say the XML had something like this


<myxml>
<section>
Some Content

<section>Some Subsection Content</section>
<section>Some Subsection Content2</section>
</section>

<section>
Some Content2
</section>
</myxml>


I've been able to recursively iterate through the sections and subsections with something like this:


<xsl:template match="/">
<xsl:apply-templates select="myxml/section" />
</xsl:template>

<xsl:template match="section">
<p><xsl:value-of select="." /></p>
<xsl:apply-templates select="section" />
</xsl:template>



What if i wanted to iterate over and display those same nodes again (in the same xsl stylesheet) but with a different template that styled it differently... how would i do that? how would i get another template to still match those nodes but override the first one?

fliptight
09-10-2008, 05:42 PM
ok nevermind i figured it out. for anyone that cares, you would use the mode attribute.


<xsl:apply-templates select="section" mode="style1" />
<xsl:apply-templates select="section" mode="style2" />

...

<xsl:template match="section" mode="style1">
...
</xsl:template>

<xsl:template match="section" mode="style2">
...
</xsl:template>