This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: sort
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: sort
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Thu, 11 May 2000 13:43:32 +0100
- Reply-To: xsl-list at mulberrytech dot com
> I am passing a parameter using
> processor.setStylesheetParam("S", "'name'");
>
> Now in my style sheet I can access the parameter like this
> <xsl:value-of select="$S">
> but if I try to use this
>
> <xsl:sort select="$S"> .. it doesn't work
>
I think it does work. The value of $S is the literal value 'name', so the
sort key for each member of the set is 'name', and when all members of the
set have the same sort key they are processed in document order.
I suspect what you want to do is to sort by the value of the child element
whose name is given in $S. Subject to small print involving namespaces, you
can do this as
<xsl:sort select="*[name()=$S]"/>
This is a FAQ. Note that the solution isn't general, for example it wouldn't
allow you to pass "@code" or "price * quantity" as the value of the sort
key. For a general solution, look at the Saxon extension function
saxon:evaluate(). Another solution is to modify the stylesheet before
execution: there's an example in my book of how to do this with MSXML3.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list