[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|