You've got your knickers in a twist. You want
<xsl:sort select="column[(_at_)name=$sortByColumn]"/>
Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Kim Tran
Sent: 01 April 2003 14:25
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Parameterized sort
I have the following sort problem where I want to have the
sort key defined
as a parameter.
For example, here is my XML:
<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>
I want to sort the list by either FirstName or LastName.
Here is my xsl
file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xalan="http://xml.apache.org/xalan">
<xsl:output method="xml"/>
<xsl:param name="sortByColumn" select="'FirstName'"/>
<xsl:template match="/"> <Document> <xsl:for-each
select="Document/row"> <xsl:sort
select="column[(_at_)name=*[name()=$sortByColumn]]"/>
<row>
<xsl:apply-templates select="column"/>
</row>
</xsl:for-each>
</Document>
</xsl:template>
<xsl:template match="column">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
However, it still doesn't work. 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.
If I say,
<xsl:sort select="column[(_at_)name='FirstName']"/>
then, it works properly.
Many thanks in advance.
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list