using xsl order-by clause on numeric attributes

webmasterbeta

New Member
I am having some trouble using the order-by clause to sort output byattributes. For example, given the following xml:<xml><schema name="TestSchema" xmlns="urn:schemas-microsoft-com:xml-data"xmlns:dt="urn:schemas-microsoft-com:datatypes"><elementtype name="items"><elementtype name="item"><attributetype name="order" dt:type="int" /></elementtype></elementtype></schema><items><item order="1" /><item order="3" /><item order="10" /><item order="5" /><item order="20" /></items></xml>I then apply the following xsl to do a transformation:<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><xsl:for-each select="xml/items/item" order-by="@order">Item #<xsl:value-of select="@order" /><br /></xsl:for-each></xsl:template></xsl:stylesheet>I expect to get the following listItem #1Item #3Item #5Item #10Item #20But instead, get this listItem #1Item #10Item #20Item #3Item #5If I change the order-by clause to order-by="number(@order)", the items arecorrectly sorted in the output. So it seems that the schema definition forthe @order attribute is not being properly recognized. Am I missingsomething simple?
 
Back
Top