Hi,
First time poster, and very new to XML and XSL. My question is this, I have a table which is sorted using xsl sort. I would like to sort it ascending when the parameter equals a certain value, say 'sortTime', otherwise sort it descending. I was hoping to set this parameter to that value using a hyperlink. I have searched high and low, and still dont even know about setting up a parameter correctly so I dont know if that is the issue or if this can even be done. Here is my code:
Any help or direction to information will be greatly appreciated.
Kind Regards
Barry T
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:param name="sortkey" />
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Euro 2012 Assignment</title>
<script language="javascript" type="text/javascript" src="weatherRss.js"></script>
<script language="javascript" type="text/javascript" src="showRSS1.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet1.css" />
<!--link rel="stylesheet" type="text/css" href="football.css" /-->
</head>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<h2><strong>RSS news feeds</strong></h2>
<br/>
<div class="centerback">
<div class="fixturesTable">
<form method="GET" action="" name="form1">
<table border="4" style="color:white; white-space: nowrap;" id="tableFix">
<tr style="color:white;" bgcolor="silver">
<td>Team Name</td>
<td>.</td>
<td>Team Name</td>
<td>Venue</td>
<td><a href="football.xml?sortkey=sortTime">Time</a></td>
</tr>
<xsl:choose>
<xsl:when test="sortkey=sortTime">
<xsl:for-each select="fixture/game">
<xsl:sort select="time" order="ascending"></xsl:sort>
<tr style="color:silver;">
<td><xsl:value-of select="teamA"/></td>
<td> VS </td>
<td><xsl:value-of select="teamB"/></td>
<td><xsl:value-of select="venue"/></td>
<th value="qwe" id="timeRow"><xsl:value-of select="time"/></th>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="fixture/game">
<xsl:sort select="time" order="descending"></xsl:sort>
<tr style="color:silver;">
<td><xsl:value-of select="teamA"/></td>
<td> VS </td>
<td><xsl:value-of select="teamB"/></td>
<td><xsl:value-of select="venue"/></td>
<th value="qwe" id="timeRow"><xsl:value-of select="time"/></th>
</tr>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</table>
<input type="submit" name="btn" value="alert" onclick="" />
</form>
</div>
</div>
<div class="rightside"></div>
<div class="leftside"></div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>