sorting - How sort XML using XSLT ascending order -
i have write xslt view bus stop information want ask how can make order in ascending stop number. can give me hand in how 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>
you can use sort in apply-templates this:
<xsl:apply-templates select="//stop"> <xsl:sort order="ascending" select="@number" data-type="number"/> </xsl:apply-templates>
Comments
Post a Comment