|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] sorting and parameters
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








