This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Parametrized xsl:sort
- From: Peter Davis <pdavis152 at attbi dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 29 Aug 2002 19:57:27 -0700
- Subject: Re: [xsl] Parametrized xsl:sort
- References: <000301c24fcb$1e3c7830$a0f26840@cisco.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
On Thursday 29 August 2002 19:15, Neale Morison wrote:
> To be specific, I want the result of:
> <xsl:sort select="$sortkey" order="descending"/>
Since a normal variable doesn't change, the sort will have no effect (but I'm
sure you already figured this out).
> with parameter sortkey:
> <xsl:with-param name="sortkey" select="@name"/>
If you pass select="@name", it will evaluate "@name" in the context of the
with-param, not in the sort. So you probably want to change this to:
<xsl:with-param name="sortkey" select="'@name'"/>
which will pass the string '@name' to be evaluated later.
> to be equivalent to:
> <xsl:sort select="@name" order="descending"/>
To evaluate the string, you need to use some kind of extension function. Look
in the documentation of whatever processor you use; it will probably look
like:
<xsl:sort order="descending" select="xxx:evaluate($sortkey)"/>
The 'xxx' will be associated with an extension namespace specific to your
processor. The evaluate() function will take the string $sortkey and
evaluate it as an XPath expression.
--
Peter Davis
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list