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

Sending parameters to XSL stylsheet

Subject: Sending parameters to XSL stylsheet
From: "Daniel J. Stahl" <ds2xa@xxxxxxxxxxxx>
Date: Fri, 30 May 2003 10:13:49 -0400
sending parameters to xsl
Hi,

I have a newbie question, but I hope you'll bear with me.  I'm
attempting to send a parameter to an XSL stylesheet.  This parameter is
designed to provide a variable to the xsl:sort function so that it can
correctly sort the XML data based on last name.

My code snippit looks like this:

 <td><a href="combined.asp?sortBy=lname">Last Name</a></td>  'this code
sends the parameter 'lname' to an .asp page

The .asp page calls the stylesheet and the stylesheet contains the usual
header information and the following parameter

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

         <xsl:param name="sortBy"/>    
          <xsl:output method="html"/>  ...	

Later in the stylesheet I try to use the sortBy parameter in the
following manner:

<xsl:sort select="name/$sortBy" data-type="text" order="ascending"/>

But I get the following dreaded error: NodeTest expected here.
name/-->$<--sortBy

If I hard code the sort select statement to say name/lname it works
fine.  But I want to be able to send the stylesheet any number of ways
to sort via parameter passing.

I also tried to capture the entire path statement as the parameter as
shown below: 

<td><a href="combined.asp?sortBy=name/lname">Last Name</a></td>  'this
code sends the parameter lname to an .asp page
      and the code on the style sheet is:
<xsl:sort select="$sortBy" data-type="text" order="ascending"/>

      The good news here is that the code does not produce the 'NodeTest
expected here.' error and will display the stylesheet, but does not sort
it.  The XML data appears in the order of its original input.

What causes this Nodetest error?  Can anyone show me how to produce code
that will prevent it?

Thank you very much

 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.