xsl-list
[Top] [All Lists]

Re: [xsl] Using xsl:sort to sort negative values

2007-02-20 15:46:12


   Can anyone tell why the code below will not work?

    <xsl:sort select="data" data-type="number"/>


well, we have to guess, as you haven't shown the relevant part of your
code, but my guess is that you have

<xsl:for-each select="data">
    <xsl:sort select="data" data-type="number"/>

which means that the sort key in each case is the string value of 
the data child of the current data element, converted to a number,
but as there are no such elements all elements get the same sort key
(NaN in xslt1, () in xslt2) and so no sorting happens.

use 

    <xsl:sort select="." data-type="number"/>

as you want the value of the element itself, not of a child.

David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--