-
using xsl order-by clause on numeric attributes
I am having some trouble using the order-by clause to sort output by
attributes. 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 list
Item #1
Item #3
Item #5
Item #10
Item #20
But instead, get this list
Item #1
Item #10
Item #20
Item #3
Item #5
If I change the order-by clause to order-by="number(@order)", the items are
correctly sorted in the output. So it seems that the schema definition for
the @order attribute is not being properly recognized. Am I missing
something simple?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks