1

I have write this XSLT to view bus stop information but I want to ask how can I make the order in ascending stop number. can someone give me a hand in how to sorted

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:element name="html">
      <xsl:element name="body">
        <table style="width:720px" border="3">
          <tr>
            <td>Stop #</td>
            <td>Route #</td>
            <td>Name</td>
            <td>latitude</td>
            <td>longitude</td>
          </tr>
          <xsl:apply-templates select="//stop" />
        </table>
      </xsl:element>
    </xsl:element>
  </xsl:template>
  <xsl:template match="stop">
    <tr>
      <td>
        <xsl:value-of select="@number" />
      </td>
      <td>
        <xsl:value-of select="routes" />
      </td>
      <td>
        <xsl:value-of select="@name" />
      </td>
      <td>
        <xsl:value-of select="location/latitude" />
      </td>
      <td>
        <xsl:value-of select="location/longitude" />
      </td>
    </tr>
  </xsl:template>
</xsl:stylesheet>
2
  • 3
    in future it would help if you can provide an example of the input XML in the question, as well as the XSLT you've tried so far. Commented Apr 6, 2014 at 21:03
  • I try to add but the system will not allow me to post it because it make my question mostly code Commented Apr 6, 2014 at 21:33

1 Answer 1

3

You can use sort in apply-templates like this:

<xsl:apply-templates select="//stop">
    <xsl:sort order="ascending" select="@number" data-type="number"/>
</xsl:apply-templates>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.