[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: format-number

Subject: Re: format-number
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2001 10:25:27 +0100
format concat
Hi Daniel,

> This is probably quite a simple question, but I have a number
> (17042000) which I want to convert into a date. I've tried
> format-number(17042000, '##/##/####'), but that doesn't work, and
> returns 17042000//, so, how would I go about converting the above
> number into something that resembled a date?

format-number() is specifically for formatting decimal numbers or
integers in ways that make them easier for people to view. You can
create groupings using format-number(), but only groupings of the same
size, so there's no way you can use it for dates.

Instead, you need to turn your number into a string and then use
substring functions to create the date format:

  concat(substring($number, 1, 2), '/',
         substring($number, 3, 2), '/',
         substring($number, 5))

> And also, I'd like to perform a test on a number to determine if
> it's positive or negative. Sgn usually does the trick, but can't see
> any reference to it in xsl. What I'd like is to use:

There's no sgn() function in XPath. You can use:

  $number >= 0

to see if a number is positive (though there may be technicalities
surrounding +/-0 that I'm not aware of).

If you really want to use a function instead, and if you're using a
processor that allows you to create your own user-defined functions,
then you could roll your own sgn() function, but I think that it will
probably prove to be more effort than it's worth considering that the
above expression is fairly simple.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.