[xsl] newbie prob - Template and navigation confusion???

Subject: [xsl] newbie prob - Template and navigation confusion???
From: "Nick Roberts" <nick_roberts5@xxxxxxxxxxx>
Date: Thu, 03 Feb 2005 13:44:23 +0000
I'm quite new the XSL and what i've have produced so far has taken some considerable time. I'm slowly getting used to the way templates work but i'm still having some probs with my code.

In the below code, there is a 'when' condition which states that the when the salary is greater than 30000, match the 'dark' template.. which sets the background colour of a table-box to grey.

Although this sort-of works, it seems to pick random boxes to turn grey, some which aren't above 30000, and others which are. Also, some which are over 30000 aren't turned grey??

I presume it must be something to do with the way i'm navigating through the xml document.

Can anyone spot any problems with the code?

Cheers, Nick


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


<xsl:template match="page">
<html>
<head><title>Footy stuff</title></head>
<body>
<h1>Football Report</h1><hr/>
<xsl:for-each select="ROWSET/ROW">
<h2><xsl:apply-templates select="TEAM/TEAM_ROW/TEAMNAME"/></h2>
<h3>Stadium: <xsl:apply-templates select="STADIUM"/></h3>
<table border="1">
<th><b>Last Name</b></th><th><b>Salary</b></th>
<xsl:choose>
<xsl:when test="TEAM/TEAM_ROW/NAME/NAME_ROW/SALARY&gt;'30000'">
<xsl:apply-templates select="TEAM/TEAM_ROW/NAME/NAME_ROW" mode="dark"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="TEAM/TEAM_ROW/NAME/NAME_ROW" mode="light"/>
</xsl:otherwise>
</xsl:choose>
</table>
<xsl:call-template name="break"/>
</xsl:for-each>
</body>
</html>
</xsl:template>


<xsl:template match="NAME_ROW" mode="dark">
<tr>
<td><xsl:value-of select="LAST_NAME"/></td><td bgcolor="gray"><xsl:value-of select="SALARY"/></td>
</tr>
</xsl:template>


<xsl:template match="NAME_ROW" mode="light">
<tr>
<td><xsl:value-of select="LAST_NAME"/></td><td><xsl:value-of select="SALARY"/></td>
</tr>
</xsl:template>


 <xsl:template name="break">
  <hr/>
 </xsl:template>

</xsl:stylesheet>

Current Thread