[xsl] Sorting with parameters

Subject: [xsl] Sorting with parameters
From: "Opstvedt, Hermod" <hermod.opstvedt@xxxxxx>
Date: Tue, 6 Feb 2001 12:03:21 +0100
Hi

I am generating a HTML file from XML using XSL, and I want to be able to
sort by clicking on selected column headers. I was thinking that maybe using
a parameter in the select of sort might do the trick, because I could then
send a different parameter value to the parser for each run. However I does
not seem to work. Is the " select="$sortName" " not the correct XPATH for
this.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
	<xsl:template match="/">
		<xsl:param name="sortName"/>
		<html><body bgcolor="lightblue">
		<table border="1">
                	<tr>
			<td onClick="return sortXSL('Seilnr')"><b>Seil
nr</b></td>
			<td><b>Navn</b></td>
			<td><b>Type</b></td>
			<td><b>Fornavn</b></td>
	            	<td><b>Etternavn</b></td>
     		      	<td><b>Postnr</b></td>
           			<td><b>Sted</b></td>
	            	<td><b>Forening</b></td>
	           		<td onClick="return
sortXSL('orctd')"><b>GPH</b></td>
	            	<td><b>P.Line Time Fact. W/L</b></td>
	            	<td><b>P.Line Dist. Fact. W/L</b></td>
	            	<td><b>P.Line Time Fact. Offsh.</b></td>
	            	<td><b>P.Line Dist. Fact. Offsh.</b></td>
	            	<td><b>Time on Time Fact.</b></td>
	            	<td><b>Mannskapsvekt</b></td>
            	</tr>
		<xsl:apply-templates select="/ORC-Liste/OrcBaat">
			<xsl:sort select="$sortName"/>
		</xsl:apply-templates>
		<tr><td> </td><td>
		<b>Total: </b>
		<xsl:value-of select="count(//orctd)" />
		</td><td>&#160;</td></tr>
		</table></body></html>
	</xsl:template>
	<xsl:template match="OrcBaat">
     	    <tr>
               <td align="left"><xsl:value-of select="Seilnr"/></td>
               <td align="left"><xsl:value-of select="bnavn"/></td>
               <td align="left"><xsl:value-of select="btype"/></td>
               <td align="left"><xsl:value-of select="fnavn"/></td>
               <td align="left"><xsl:value-of select="enavn"/></td>
               <td align="left"><xsl:value-of select="ponr"/></td>
               <td align="left"><xsl:value-of select="pstd"/></td>
               <td align="left"><xsl:value-of select="forening"/></td>
               <td align="left"><xsl:value-of select="orctd"/></td>
               <td align="left"><xsl:value-of select="orcptB"/></td>
               <td align="left"><xsl:value-of select="orcpdB"/></td>
               <td align="left"><xsl:value-of select="orcptO"/></td>
               <td align="left"><xsl:value-of select="orcpdO"/></td>
               <td align="left"><xsl:value-of select="orctt"/></td>
               <td align="left"><xsl:value-of select="mankg"/></td>
             </tr>
	</xsl:template>
</xsl:stylesheet>

Hermod Opstvedt
Chief Architect IT-01
Den norske Bank
DnB IT EK - INTER/INTRANETT
Postboks 7100
5020 Bergen, Norway
Phone : (+47) 55 21 90 64 / Mob: (+47) 957 40041 
EMail: hermod.opstvedt@xxxxxx
WWW: http://www.dnb.no



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that DnB cannot
accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the virus programs used
in the DnB Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread