sorting and parameters

Subject: sorting and parameters
From: Perry Roland <pdr4h@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2000 09:04:25 -0500
I'm greatly appreciative of the help I've received from the list.  I
think I'm learning a lot, but I've run up against another stumbling
block: How do I pass a sort key to a stylesheet?

Here's my XML --


I want to be able to sort by title or by num using the same stylesheet.

Here's my stylesheet --

<xsl:stylesheet version="1.0" xmlns:xsl="";>
<xsl:param name="key">title</xsl:param>
<xsl:param name="sortorder">ascending</xsl:param>

<xsl:template match="/">
<BODY BGCOLOR="#ffffff">
<xsl:apply-templates select="hitlist"/>

<xsl:template match="list">
                <xsl:apply-templates select="item">
                        <xsl:sort select="{$key}" order="{$sortorder}"/>

<xsl:template match="item">
		<xsl:value-of select="title"/><BR/>
		<xsl:value-of select="num"/>


Using Saxon, I get the error "Invalid character ({) in expression {$key}".
I think the syntax is right because I have no problem with the sortorder
parameter.  I suspect the difference may be because the sortorder
parameter is a string while the key parameter is a collection of nodes,
but I don't know how to proceed from there.  Any help would be greatly


 XSL-List info and archive:

Current Thread