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

Re: Number formatting: <xsl:number> vs. format-number()

Subject: Re: Number formatting: <xsl:number> vs. format-number()
From: David_Marston@xxxxxxxxx
Date: Thu, 13 Jul 2000 16:10:21 -0400
xsl number format number
Ragnar Schierholz asks what could be a FAQ:
>For some reason I get both the newly formatted and the original number
>when I use the "format-number" function but only the newly formatted
>number when I use <xsl:number>. Is this behaviour correct?

You should be using xsl:number only to generate numbering on outputted
items. Yes, <xsl:number value="number-expression" ...> is capable of
applying some limited formatting to the expression IF that expression
is a positive integer, but format-number() gives much better control.
You can use xsl:number to format number-expressions into Roman
numerals if you wish, and that might have been your intent in the
example you gave, but as a general rule xsl:number is not the tool to
format values stored in variables.

You said format-number($combinationIndex,'I') in your example, but
format-number uses formatting strings (second argument) that are more
pictorial than the limited xsl:number vocabulary. One thing that both
do is pass through non-magic strings, like so:
format-number(12,'(##)') gives '(12)'
<xsl:number value="12" format="(1)"/> gives '(12)'
In both cases, the parentheses are non-magic and thus just come out
as-is. But I is non-magic in format-number, so you were asking for
return of a constant 'I' with nothing representing the value to be
formatted! When using format-number(), plan on explicitly marking
every decimal place, the decimal point, all commas, etc.

Furthermore, notice that format-number() is a function that
returns a string, so additional processing like use of other
string functions can be applied. OTOH, xsl:number is an output
instruction, just like xsl:value-of.
.................David Marston


 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.