RE: [xsl] sorting problem

Subject: RE: [xsl] sorting problem
From: "Ray Lukas" <rlukas@xxxxxxxxxxx>
Date: Wed, 14 Feb 2001 14:16:50 -0500

It looks like you are sorting alphabetically instead of numerically.

I am just learning this stuff (xml  and xsl that is)..... So forgive me if
this does not help, Know at least that I did try.

I am going through the tutorials
and I found this example. Perhaps it will be of help to you. I myself am
still working at figuring it out. For instance how does <xsl:if test="@id">
really work. I don't understand the @id thing here. Perhaps you could tell
me about the id thing.. I see no "id" in the sort.xml.... See the datatype
number that might stop it from doing the numeric to alpha convert prior to
the sorting. I don't know for sure but maybe give it a try....

Sorting Example
Figure 19. sort.xml
<para>Here's a table of sales:</para>
<row><cell>3000</cell><cell>Widgets 'R' Us</cell></row>
<row><cell>2400</cell><cell>Widget Design and Implementation</cell></row>
<row><cell>10000</cell><cell>Widgets for Dummies</cell></row>
<row><cell>101</cell><cell>101 Uses for a Dead Widget</cell></row>

Figure 20. sort.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="";

<xsl:import href="element.xsl"/>

<xsl:template match="table">
  <xsl:if test="@id"><a name="{@id}"/></xsl:if>
    <xsl:apply-templates select="row">
      <xsl:sort data-type="number" select="./cell[1]"/>

Figure 21. sort.html
<p>Here's a table of sales:</p>
<td>101</td><td>101 Uses for a Dead Widget</td>
<td>2400</td><td>Widget Design and Implementation</td>
<td>3000</td><td>Widgets 'R' Us</td>
<td>10000</td><td>Widgets for Dummies</td>

Ray Lukas
(work) 978.262.6297
(fax) 978.262.6777

 -----Original Message-----
From: 	owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]  On Behalf Of Awasthi, Anand
Sent:	Wednesday, February 14, 2001 1:24 PM
To:	'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject:	[xsl] sorting problem

 hi i am trying to sort following xml :


in desecnding order using following  xsl:

<xsl:stylesheet version="1.0"
  <xsl:template match="AAA">
      <xsl:apply-templates  select="BBB">
	        <xsl:sort data-type="number"  order="descending"

but everytime i am getting following output :

1 10 11 1111 22 2222 44344444

but acrually it should be :

1 10 11 22 1111 2222 44344444

i am not sure what the problem is ??

could somoene pls look into above xsl  piece and le t me know the problem ??


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread