By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

XSL sorting version number strings

P: 2
I am not that familiar with XML or XSL and I am trying to sort application version number strings in an XML file that my team uses for application installations on our Linux servers. I have tried the xsl:data-type=number, but that doesn't work. The output of the XML file is exactly what the XML file has and I would like to sort it by the number value.

Below is the some of the output from the XML file.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="releases.xsl"?>
  3. <applications>
  4.   <application>
  5.     <name>AAT</name>
  6.     <versions>
  7.       <version>4.0.1.10</version>
  8.       <version>4.0.1.13</version>
  9.       <version>4.0.1.14</version>
  10.       <version>4.0.1.15</version>
  11.       <version>4.0.1.16</version>
  12.       <version>4.0.1.8</version>
  13.       <version>4.0.1.9</version>
  14.       <version>4.0.3.1</version>
  15.       <version>4.0.3.10</version>
  16.       <version>4.0.3.11</version>
  17.       <version>4.0.3.12</version>
  18.       <version>4.0.3.13</version>
  19.       <version>4.0.3.14</version>
  20.       <version>4.0.3.15</version>
  21.       <version>4.0.3.16</version>
  22.       <version>4.0.3.17</version>
  23.       <version>4.0.3.2</version>
  24.       <version>4.0.3.3</version>
  25.       <version>4.0.3.4</version>
  26.       <version>4.0.3.5</version>
  27.       <version>4.0.3.6</version>
  28.       <version>4.0.3.7</version>
  29.       <version>4.0.3.8</version>
  30.       <version>4.0.3.9</version>
  31.     </versions>
  32. </applications>
  33.  
Here is the XSL file.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0"
  3.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4. <xsl:output method="html"/>
  5.  
  6.   <xsl:template match="/applications">
  7.     <head>
  8.       <title>Available Application Releases</title>
  9.       <link rel="stylesheet" href="http://hsosm1/ctrl/inc/main.css" type="text/css" />
  10.     </head>
  11.     <body>
  12.       <table align="center" border="1">
  13.           <tr>
  14.             <td><b>Application</b></td>
  15.             <td><b>Release</b></td>
  16.           </tr>
  17.         <xsl:for-each select="application">
  18.           <tr>
  19.            <td valign="top"><xsl:value-of select="name" /></td>
  20.              <td>
  21.                <table border="0">
  22.                  <xsl:for-each select="versions/version">
  23.                    <tr><td><xsl:value-of select="." /></td></tr>
  24.                  </xsl:for-each>
  25.                </table>
  26.              </td>
  27.           </tr>
  28.         </xsl:for-each>
  29.       </table>
  30.     </body>
  31.   </xsl:template>
  32. </xsl:stylesheet>
  33.  
TIA,

Elliot
Oct 17 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.