Subject: multiple sorting From: "Caras, Yuko" <Yuko_Caras@xxxxxxxxxxxxxxxxx> Date: Tue, 15 Aug 2000 09:55:08 -0700 |
Hello, I'd followed the discussion about multiple sorting a while ago. I'm having a very similar situations but would like to add more functions. In addition to sort multiple times in client side, I would like to define different data-type for different elements and assign either ascending or descending. Is this possible? What I did was adding <xsl:choose>, but this didn't work. Am I doing wrong or is there any way to do it? What I want to do is if data-type is text, sort ascending and if data-type is number, sort descending. Thank you very much for any help. Yuko XML file -------- <result> <data> <row count="1"> <name>Bob</name> <score>80</score> <time>120</time> <lead>Mike</lead> </row> <row count="2"> ................. </row> </data> </result> XSL is -------- I set a parameter, like Bryce did... <xsl:param name="item" select="'name'"/> and in a html table output, <xsl:for-each select="row"> <xsl:sort select="./*[name() = $item]"/> <xsl:choose> <xsl:when test="$item='score'"> <xsl:for-each select="score"> <xsl:sort order="descending" data-type="number" select="."/> </xsl:for-each> </xsl:when> <xsl:when test="$item='time'"> <xsl:for-each select="time"> <xsl:sort order="descending" data-type="number" select="."/> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="row"> <xsl:sort order="descending" select="."/> </xsl:for-each> </xsl:otherwise> </xsl:choose> <tr> <xsl:for-each select="name"> <td><xsl:value-of select="."/></td> </xsl:for-each> <xsl:for-each select="score"> <td><xsl:value-of select="."/></td> </xsl:for-each> <xsl:for-each select="time"> <td><xsl:value-of select="."/></td> </xsl:for-each> <xsl:for-each select="lead"> <td><xsl:value-of select="."/></td> </xsl:for-each> </tr> </xsl:for-each> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Passing cookies into an xsl:var, Joshua Allen | Thread | Re: multiple sorting, Jeni Tennison |
RE: Passing cookies into an xsl:var, Ben Robb | Date | New book on XSLT, tedken |
Month |