RE: Sending parameters to XSL stylsheet
each xslt processor has a differnt method for getting a parameter into xslt process. note you should prob always put xsl:param after xsl:output statement here is a few ways http://www.biglist.com/lists/xsl-list/archives/200103/msg01037.html check out the tutorials at http://www.bayes.co.uk/xml/ gl, jim fuller -----Original Message----- From: Daniel J. Stahl [mailto:ds2xa@xxxxxxxxxxxx] Sent: 30 May 2003 15:14 To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: Sending parameters to XSL stylsheet 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 This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient please contact the sender immediately. Any disclosure, copying, distribution or any other use of this communication is strictly prohibitedand may be unlawful. Stuart Lawrence Marketing Communications Limited reserves the right to monitor and intercept communications for unlawful business purposes. This also confirms that this message has been swept for viruses, although Stuart Lawrence Marketing Communications Limited accepts no responsibility for any loss or damage resulting directly or indirectly from the use of this email or contents. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format