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

RE: dynamic sorting

Subject: RE: dynamic sorting
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 5 Feb 2004 17:01:25 -0000
xsl dynamic sorting
Dynamic sorting is a FAQ, though your example is unusual since you seem
to be selecting the node-set to be sorted dynamically, rather than the
sort key.

If your parameter is always an element name, you can use
*[name()=$param]. If it's a more general XPath expression, you need the
xx:evaluate() extension function offered by some products, which allows
you to treat a string as an XPath expression.

In your example $sort is the string "person", not the XPath expression
"person".

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Peter Billen
> Sent: 05 February 2004 15:02
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  dynamic sorting
> 
> 
> Hello all,
> 
> I'm breaking my head on some problem, and I hope you can help 
> me with it.
> 
> Imagine the following part of an xml file:
> 
> <person>
> 	<fname>Jup</fname>
> 	<lname>Nope</lname>
> 	<bday>Also</bday>
> 	...
> </person
> 
> The following works perfect:
> 
> <xsl:template match="/">
> 	<xsl:apply-templates select="person">
> 		<xsl:sort select="person/fname"/
> 	</xsl:apply-templates>
> </xsl:template>
> 
> But when I put the string "person" into a parameter named 
> "sort", it doesn't work anymore:
> 
> <xsl:template match="/">
> 	<xsl:param name="sort">person</xsl:param>
> 	<xsl:apply-templates select="$sort">
> 		<xsl:sort select="person/fname"/
> 	</xsl:apply-templates>
> </xsl:template>
> 
> My goal is that the user of my xsl file can give a parameter 
> "sort" (to his xslt parser) which defines his preferred way 
> of sorting.
> 
> Any ideas what is wrong?
> 
> Thanks a lot,
> 
> --
> Peter
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 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.