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 --

<list>
        <item>
                <title>Blurf</title>
                <num>1</num>
        </item>
        <item>
                <title>Barf</title>
                <num>2</num>
        </item>
</list>

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="http://www.w3.org/1999/XSL/Transform";>
<xsl:param name="key">title</xsl:param>
<xsl:param name="sortorder">ascending</xsl:param>

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

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

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

</xsl:stylesheet>

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
appreciated.

--
perry


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


Current Thread