[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: dynamic sorting
This is a FAQ <xsl:param name="sort">person</xsl:param> That makes $sort in to a result tree fragment consisting of a root node and a text node with the string "person". It's an error to query in to a result tree fragment and so <xsl:apply-templates select="$sort"> is an error. In XSLT2 it's not an error but it will apply templates to that new document that just contains the string person and no element nodes, so it will do the wrong thing. If you had done <xsl:param name="sort" select="person"/> then the sort param would have been the person element and so <xsl:apply-templates select="$sort"> would be legal although then the current node would be the person elements and so you probably would want <xsl:sort select="fname"/> rather than <xsl:sort select="person/fname"/ unless person elements have a person child. The whole thing looks suspicous as it is in a template for / if you are in a well formed document there can only be one element child of / and so you are sorting a list of one. 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. so you will probably be passing in a string and you want to sort on an element with that name, so faq answer is <xsl:sort select="*[name()=$sort]"/> But again you need to make sure you are sorting a list of more than one thing David -- http://www.dcarlisle.demon.co.uk/matthew ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ 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
|