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

RE: Dynamic XSL Sorting - Is there a way like this?

Subject: RE: Dynamic XSL Sorting - Is there a way like this?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 24 Jul 2002 09:13:53 +0100
dynamic xsl sort
> The issue is the sort.  If I use and hard code the following 
> it works: <xsl:for-each 
> select="HRISReport/Participants/Participant/Plans/Plan/Contrib
> utionRateChanges/C
> ontributionRateChange/RateChanges/RateChange">
> 	<xsl:sort select="../../../../../../LastName"/>
> 	<xsl:sort select="../../../../../../@SSN"/>
> 	
> This sorts properly but if I try to pass in a parameter 
> things start to fail.
> 
> The following works:
> <xsl:param name="sortBy" select="'Name'"/>
> 
> works if the sort reads:
> <xsl:sort select="@*[name(.)=$sortBy]"/>
> 
> <xsl:param name="sortBy" select="'OldPercent'"/>
>  works if the sort reads:
> <xsl:sort select="*[name(.)=$sortBy]"/>
> 
> But how do I sort off of LastName,FirstName or SSN as a 
> parameter.  None of these fields appear to work unless I 
> hardcode the sort. 

One solution is to use xx:evaluate(), which evaluates any XPath
expression supplied as a string. This is available in some processors
including Saxon and Xalan.

You might also be able to achieve the required effect with a generic
expression that searches for an ancestor having a child or attribute
with the right name:

<xsl:sort select="(ancestor-or-self::*/* | ancestor-or-self::*/@*)
                   [name()=$param][last()]"/>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 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.