Re: XSL Sort and Xalan
Bryce, >But, I would like the end-user to be able to sort this data in the HTML >page, without making another call to the database (which is generating the >XML) - and was hoping to accomplish this by creating a parameter that would >trigger the proper column to sort. > >So, I created the parameter and gave it a static value (I'll pass them >dynamically later) ><xsl:param name="item" select="'RECORD/LENGTH'"/> In your example, you've set the value of the parameter $item to the string 'RECORD/LENGTH'. Similarly, if the parameter is passed in by the XSLT processor, the value is going to be a string. The value of the 'select' attribute of xsl:sort is interpreted as an XPath, generating a node set whose value is used to give the value of the node on which it will be sorted. Using: <xsl:sort select="$item" /> has the same effect as: <xsl:sort select="'RECORD/LENGTH'" /> As a string, $item gives the same value ('RECORD/LENGTH') each time it is processed. As each OBJECT_TABLE is given the same value for the sort, they are sorted in the order that they appear in the source. Strings cannot be interpreted as node sets (this has been recently covered in another thread) unless you use extension functions such as saxon:node-set. What you *can* do (and the solution is blessedly straight-forward in your case) is construct an XPath that uses the value of $item to identify the value that should be used to sort the OBJECT_TABLEs: <xsl:sort select="RECORD/*[name() = $item]" /> In other words, sort the OBJECT_RECORDs on the value of the first child element of a RECORD element child of the OBJECT_RECORD, that has the same name as $item. I hope this helps, Jeni Dr Jeni Tennison Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx 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