Subject: RE: Parameterized sort
From: Stuart Brown <sbrown@xxxxxxxxxxx>
Date: Tue, 1 Apr 2003 14:46:03 +0100
|
Hi Kim,
> I have the following sort problem where I want to have the
> sort key defined
> as a parameter.
...
> <document>
> <row><column name="FirstName">John</column>
> <column name="LastName">Doo</column>
> </row>
> <row><column name="FirstName">Alice</column>
> <column name="LastName">Mulcaster</column>
> </row>
...
> <xsl:sort select="column[@name=*[name()=$sortByColumn]]"/>
Your problem is that you are trying to treat the attribute value as if it
were an element, and using the wildcard and name() functions. You are
overcomplicating things: all you need to do is sort by the column element
whose name attribute value (a string) equates to the parameter (another
string); this is a simple comparison. Just try
<xsl:sort select="column[@name=$sortByColumn]"/>
Hope that helps,
Stuart
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|