xsl-list
[Top] [All Lists]

RE: Parameterized sort

2003-04-01 07:00:35
Hi Kim,

[...]

 I know that the sort key if 
defined as 
parameter, I should use "xalan:evalue($sortKey)" or "*[name() 
= $sortKey]".  
In this case, I want to sort the rows by the FirstName column 
or by LastName 
column and First Name.

You don't need the evalue function, or name() here.

If I say,
<xsl:sort select="column[(_at_)name='FirstName']"/>
then, it works properly.

so just use
        <xsl:sort select="column[(_at_)name=$sortKey]"/> 
where $sortKey contains either "FirstName" or "LastName". 

You've given the columns @name attributes, so you don't need the name()
function.

On the other hand, if you had
<row>
        <columnA>foo</columnA>
        <columnB>bar</columnB>
</row>
and you wanted to sort either on columnA or columnB, you'd use
        <xsl:sort select="*[name()=$sortKey]"/>

HTH,
Tom SW

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



<Prev in Thread] Current Thread [Next in Thread>