[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Parameterized sort
You've got your knickers in a twist. You want <xsl:sort select="column[@name=$sortByColumn]"/> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Kim Tran > Sent: 01 April 2003 14:25 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Parameterized sort > > > I have the following sort problem where I want to have the > sort key defined > as a parameter. > > For example, here is my XML: > <document> > <row><column name="FirstName">John</column> > <column name="LastName">Doo</column> > </row> > <row><column name="FirstName">Alice</column> > <column name="LastName">Mulcaster</column> > </row> > > I want to sort the list by either FirstName or LastName. > Here is my xsl > file: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0" xmlns:xalan="http://xml.apache.org/xalan"> > <xsl:output method="xml"/> > > <xsl:param name="sortByColumn" select="'FirstName'"/> > <xsl:template match="/"> <Document> <xsl:for-each > select="Document/row"> <xsl:sort > select="column[@name=*[name()=$sortByColumn]]"/> > <row> > <xsl:apply-templates select="column"/> > </row> > </xsl:for-each> > </Document> > </xsl:template> > > <xsl:template match="column"> > <xsl:copy-of select="."/> > </xsl:template> > </xsl:stylesheet> > > However, it still doesn't work. I know that the sort key if > defined as > parameter, I should use "xalan:evalue($sortKey)" or "*[name() > = $sortKey]". > In this case, I want to sort the rows by the FirstName column > or by LastName > column and First Name. > > If I say, > <xsl:sort select="column[@name='FirstName']"/> > then, it works properly. > > Many thanks in advance. > > > > > > _________________________________________________________________ > Add photos to your messages with MSN 8. Get 2 months FREE*. > http://join.msn.com/?page=features/featuredemail > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > 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
|