This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

<xsl:sort> Q



Hi,

I have a simple sort Q. I am trying to sort numbers for a select box in
ascending order. After running it through the  XSLT processor, what I do
get is a sort, however, it is sorting based on the first digit of the
number. By doing so, it considers the number "3" to be greater than the
number "27". How do I avert this sorting? ANd I cannot make ID as an
attribute.

Here is a sample XML"

<Names>
  <Name>
    <Description>abc</Description>
    <ID>30</ID>
  </Name>
  <Name>
    <Description>aaa</Description>
    <ID>7</ID>
  </Name>
  <Name>
    <Description>bbb</Description>
    <ID>27</ID>
   </Name>
  <Name>
    <Description>bbb</Description>
    <ID>2</ID>
   </Name>
</Names>


Sample XSL:

...
<xsl:template match="/">
<select name="numberlistbox" size="10">
     <xsl:apply-templates select="Names/Name">
          <xsl:sort select="ID" />
     </xsl:apply-templates>
</select>
...
</xsl:template>

<xsl:template match="Name">
<option>
<xsl:value-of select="ID" />
</option>
</xsl:template>

Result:

ID's are:
2
27
30
7

Desired result:

2
7
27
30

Any help is appreciated.

Thanks,

Maulik


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]