|
[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?
> 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
|
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
|

Cart








