[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: sorting problem
Anand: 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 http://www.nwalsh.com/docs/tutorials/xsl 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 <doc> <para>Here's a table of sales:</para> <table> <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> </table> </doc> Figure 20. sort.xsl <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="element.xsl"/> <xsl:template match="table"> <xsl:if test="@id"><a name="{@id}"/></xsl:if> <table> <xsl:apply-templates select="row"> <xsl:sort data-type="number" select="./cell[1]"/> </xsl:apply-templates> </table> </xsl:template> </xsl:stylesheet> Figure 21. sort.html <p>Here's a table of sales:</p> <table> <tr> <td>101</td><td>101 Uses for a Dead Widget</td> </tr> <tr> <td>2400</td><td>Widget Design and Implementation</td> </tr> <tr> <td>3000</td><td>Widgets 'R' Us</td> </tr> <tr> <td>10000</td><td>Widgets for Dummies</td> </tr> </table> Ray Lukas RLukas@xxxxxxxxxxx (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: sorting problem hi i am trying to sort following xml : <AAA> <BBB>1</BBB> <BBB>22</BBB> <BBB>11</BBB> <BBB>2222</BBB> <BBB>1111</BBB> <BBB>10</BBB> <BBB>444444</BBB> </AAA> in desecnding order using following xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="AAA"> <xsl:apply-templates select="BBB"> <xsl:sort data-type="number" order="descending" select="."/> </xsl:apply-templates> </xsl:template> </xsl:stylesheet> 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 ?? thanks Anand 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
|