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

Re: Parametrized xsl:sort

Subject: Re: Parametrized xsl:sort
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Thu, 29 Aug 2002 22:31:46 -0700
Re:  Parametrized xsl:sort
On Thursday 29 August 2002 21:03, Neale Morison wrote:
> Thanks. I thought I might be able to do it without an eval, but the eval
> method does work. Regards,
> Neale

The only other way to do it is to have a preset list of possible sort keys, 
and use <xsl:choose>.  It's not as useful, but it will work without the 
extension.

        <xsl:call-template name="petTable">
                <xsl:with-param name="selection" 
select="pet[@species='dog']"/>
                <!-- use quotes around '@name' -->
                <xsl:with-param name="sortkey" select="'@name'"/>
                <xsl:with-param name="sortorder" select="'descending'"/>
        </xsl:call-template>

        <xsl:template name="petTable">
                <xsl:param name="selection" select="*"/>
                <xsl:param name="sortkey" select="''"/>
                <xsl:param name="sortorder" select="''"/>
                ...
                <xsl:choose>
                   <xsl:when test="$sortkey = '@name'">
                     <xsl:apply-templates select="$selection">
                        <!-- just a question, did you mean to parameterize the
                             sort order as well? -->
                        <xsl:sort select="@name" order="descending"/>
                     </xsl:apply-templates>
                   </xsl:when>
                   <xsl:when test="$sortkey = 'something else'">
                      <!-- copy the same apply-templates here, changing @name
                           as appropriate -->
                   </xsl:when>
                </xsl:choose>
        ..>
        </xsl:template>


-- 
Peter Davis

 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.