xsl-list
[Top] [All Lists]

Param in xsl:sort select

2003-06-04 02:39:51
Hello

I'm trying to pass a string value as a parameter to my stylesheet. That value 
is supposed to control the sorting of contacts. 

I have a solution that works but the expression used in my xsl:sort select 
attribute looks horrible (./*[local-name()=$sortParam]). I want to use 
something like 
<xsl:sort select="$sortName"/> instead but that doesn't work. Why?

I have used MSXML4.0.

Thanks in advance

/Marcus

Example XML:

<contacts>
 <contact>
  <firstName>a first name</firstName>
  <lastName>a last name</lastName>
  ...
 </contact> 
 ...
 ...
</contacts>

XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:param name="sortParam">firstname</xsl:param>

  <xsl:template match="contacts">
    <table cellspacing="0" cellpadding="0" border="1">
      <tr><td>Name</td><td>Tele</td><td>Email</td><td>Homepage</td></tr>
        <xsl:apply-templates select="contact">
            <xsl:sort select="./*[local-name()=$sortParam]"/>
        </xsl:apply-templates>
      </table>
  </xsl:template>
...
</xsl:stylesheet>


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



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