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