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

Re: XSL Sort and Xalan

Subject: Re: XSL Sort and Xalan
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 03 Aug 2000 23:40:46 +0100
sorting with xalan nodeset
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


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.