XML sorting by numbers
1 posts in topic
Flat View  Flat View

Posted By:   Joel_Pifer
Posted On:   Wednesday, November 12, 2008 01:38 PM

I am trying to create a XSL stylesheet for my XML page. I want to sort the information by the prices, for example, $2.95, then $3.25, then $4.25, then $5.49, then then $7.35, then $10.25. how do i do this? without organizing the code in that order?

(PRICE is the element>

I used xsl:sort select="PRICE" but with that it took $10.25 and placed it at the top, then $2.95.

then i used xsl:sort select="PRICE" data-type="number" instead. but that took 7.35, then 2.95, then 10.25. in that order.

How can I get the prices to list from least to greatest?

Re: XML sorting by numbers

Posted By:   Robert_Lybarger  
Posted On:   Friday, November 14, 2008 09:16 AM

I'm not near an XSLT tool right now, so this is only a guess.. but the "select" in xsl:sort is an 'expression'. This makes me think you could try "select=substring-after(.,'$')" and also note xsl:sort has another attribute to force treatment of the values as numbers. The sorting you are getting makes sense, to me, if the "$" symbol is forcing into a lexicographical sort.
About | Sitemap | Contact