[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Param in xsl:sort select

Subject: Param in xsl:sort select
From: "Marcus Andersson" <marcan@xxxxxxx>
Date: Wed, 4 Jun 2003 11:39:51 +0200
xsl sort select param
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.