[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: formatting numbers and dates
>I'm brand new to XSL so forgive my ignorance, but I'm trying to use >format-number() and can't seem to figure out the proper syntax. If you're having problems with the function, the first step is to get an up-to-date XSL processor. Only recently-issued ones, like Xalan 0.19.1 from Apache, have this function working well. >Could someone show me how to convert the results of something >simple like <xsl:value-of select="cost"/> so that it displays >as currency, like $12.00. format-number(cost,'###0.00') causes cost to be formatted with 1-4 places before the decimal point, and 2 places after. The # signals zero suppression, while the 0 signals display of any digit. The spec says (section 12.3, first paragraph) that the currency sign 0x00A4 must not be in the pattern string, but you could concatenate it in front. >Is there a similar function for converting a date the is in >yyyymmdd format? There is no function that is specifically aware of dates, but you can use format-number to produce strings with the desired leading zeroes and punctuation. To map the "mm" field to month names, you could just use xsl:if. David Marston LotusXSL Team XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|