In my XSL document i want to style the document so i can do an if statment saying if the stage name is "Main Stage" display these bands. Else if its anything else displays these bands.
in my xsl document so far i have.
<table width="60%">
<b><i><xsl:value-of select="stagelist/stage/@name"/></i></b>
<tr>
<th align="left"><u>Band Name</u></th>
<th align="left"><u>Time</u></th>
</tr>
<xsl:for-each select="stagelist/stage/band">
<xsl:sort select="time"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="time"/></td>
</tr>
</xsl:for-each>
</table>
So i want to show two tables, one with all the bands from the stage with the name attribute "Main Stage" and the rest afterwards.
Subject:Probably very simple. Author:James Durning Date:08 Jan 2007 01:47 PM
If you want to list it per stage you could have your for-each loop reference each stage, eg.:
<xsl:for-each select="stagelist/stage">
<table width="60%">
<b><i><xsl:value-of select="@name"/></i></b>
<tr>
<th align="left"><u>Band Name</u></th>
<th align="left"><u>Time</u></th>
</tr>
<xsl:for-each select="band">
<xsl:sort select="time"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="time"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
to conditionally select the stage 'Main Stage': at least 3 different ways:
1. Seperate for-each 's
<xsl:for-each select="stagelist/stage[@name='Main Stage']">
...
and <xsl:for-each select="stagelist/stage[@name <> 'Main Stage']">
for the rest.
2. Use templates:
<xsl:apply-templates select="stagelist/stage"/>
and have two templates
<xsl:template match="stage[@name='Main Stage']">
...
<xsl:template match="stage"> <!-- automatically falls to this if it doesn't match the first one -->
3. Same for-each, but use an <xsl:choose>
<xsl:for-each select="stagelist/stage">
<xsl:choose>
<xsl:when test="@name='Main Stage'">...</xsl:when>
<xsl:otherwise>...</xsl:otherwise>
</xsl:choose>
</xsl:for-each>