Subject: RE: multiple sorting From: Joshua Allen <joshuaa@xxxxxxxxxxxxx> Date: Tue, 15 Aug 2000 11:19:49 -0700 |
Sorting dynamically client-side really implies that your browser supports XML (which means IE today) and if you are using <xsl:sort..> means that they have a current version of the XSLT processor installed on the client. Given these conditions, you can use something similar to the sample at http://msdn.microsoft.com/xml/samples/portfolio/sort.htm the basic idea is the you use javascript to create the filtered/sorted output and use DHTM .innerHTML to place this in an element somewhere. The example above does not do any pretty formatting, but I pointed to it because it should be easy to understand, and you should be able to see from there if you will need to change the way the DOM is accessed or something to make it compatible with Netscape 6 when it releases. Also you may want to experiement with that version calling XSLT transform. The basic idea is to use DHTML DOM, which is illustrated there though. For a dynamic client sort sample with prettier formatting, see http://msdn.microsoft.com/xml/samples/stock-sorter/stock-sorter.xml. Thanks, Joshua > -----Original Message----- > From: Caras, Yuko [mailto:Yuko_Caras@xxxxxxxxxxxxxxxxx] > Sent: Tuesday, August 15, 2000 9:55 AM > To: 'XSL-List@xxxxxxxxxxxxxxxx' > Subject: multiple sorting > > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: multiple sorting, Jeni Tennison | Thread | Any ideas, Chris Bayes |
New book on XSLT, tedken | Date | XSL command for XLink attributes?, Eliza . Khosrova |
Month |