XSL/XPATH and sorting abs(number)

XSL/XPATH and sorting abs(number)

Post by Richa » Sun, 30 Sep 2001 01:43:25



I noticed that XPATH has a floor,ceiling,round and sum functions but
no absolute function for numbers. How can I sort nodes by using
absolute values???

For example, I would like to do the following

order="descending"/>

I could put the absolute number into the XML data, but I thought there
should be an easier way/XSL-XPath way.

Thanks
Rich

 
 
 

XSL/XPATH and sorting abs(number)

Post by Marr » Tue, 02 Oct 2001 16:37:38


Rich,

try...
http://www.topxml.com/snippetcentral/main.asp?view=viewsnippet&lang=&...

e.g.
XML:-
<root>
  <a>-123</a>
  <a>123</a>
  <a>-1.0</a>
  <a>2.0</a>
  <a>-3.0</a>
  <a>3.0</a>
</root>

XSLT:-
<xsl:for-each select="root/a">
<xsl:sort select="concat(substring('-', 2 - (. &lt; 0)),'1') * ."
data-type="number"/>
 ...
</xsl:for-each>

HTH
Marrow
www.marrowsoft.com


> I noticed that XPATH has a floor,ceiling,round and sum functions but
> no absolute function for numbers. How can I sort nodes by using
> absolute values???

> For example, I would like to do the following

> order="descending"/>

> I could put the absolute number into the XML data, but I thought there
> should be an easier way/XSL-XPath way.

> Thanks
> Rich


 
 
 

XSL/XPATH and sorting abs(number)

Post by Oliver Becke » Tue, 02 Oct 2001 18:38:31



> How can I sort nodes by using
> absolute values???

> For example, I would like to do the following

> order="descending"/>


takes the square as sort key, ie does what you want.
Cheers,
Oliver

--
/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |

|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/

 
 
 

1. Sorting Numbers using XSL.

Hi,

I am trying to sort some numbers using a xsl (code is given below). But the
result of the sorting is not what is expected.

I need some help to find out why the xsl dosen't work.

Regards,

Soumitra

xsl:

<Root>
  <xsl:for-each order-by="+ Code" select="SearchRecord"
xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <SearchRecord>
      <xsl:attribute name="SupplierID"><xsl:value-of
select="SupplierID"/></xsl:attribute>
      <xsl:for-each select="BuyerCatalog">
       <xsl:attribute name="Code"><xsl:value-of

       <xsl:attribute name="Message"><xsl:value-of

      </xsl:for-each>

    </SearchRecord>
   </xsl:for-each>
</Root>

2. Old ISDN TA's are failing - What to do?

3. Number() sorting in XSL

4. vc++, crecordset, cstring = Memory allocation error

5. xsl:sort when mix of numbers and null values

6. Cable Splitters & Amplifiers

7. Newbie xsl:sort and numbering question

8. Adaptec Ultra 160 Support

9. xsl:sort problems with large number

10. How do i sort a list of numbers using XSL

11. XSL Sorting of Large Amounts of Data using the number() method

12. setting xsl:number to start numbers with 0 ?

13. Can I call xsl:number() from diff templates and output continous number