Re: XSLT Feature request
Hi Frank, > As it seems, there is only one setting in the above element and this > affects everything. So we cannot change the stylesheet only, but > switching output format means changing the decimal-format, every > format in the stylesheet and every incoming data-source. Couldn't > there be a spearate setting for output-decimal-separator, > stylesheet-decimal-separator and input-decimal-separator (maybe with > default value taken from decimal-separator for compatibility > reasons) in the next (whatever) XSLT standard?? I *think* that XSLT already gives you what you need, but I might have missed something in your description. XPath can only convert a string to a number if it uses a '.' as a decimal separator and doesn't have any other non-decimal, non-whitespace characters (so input numbers can't have grouping separators). So the results of number() are *always*: <number> 12.5 </number> => 12.5 <number> foo </number> => NaN <number> 12,5 </number> => NaN <number> 1,234.5 </number> => NaN You said that the data holds numbers in the "usual programming way" so I guess that this will allow you to get the numbers as they should be? The point of the xsl:decimal-format element is solely to interpret the format pattern string that you use in format-number(). By default it uses '.' for decimal points and ',' as the grouping separator so: format-number(1234.5, '#,##0.00') => '1,234.5' But you can override the default decimal format so that you can use a different decimal point and grouping separator: <xsl:decimal-format decimal-separator="," grouping-separator="." /> If you want to use that decimal format, you have to change the format pattern in the format-number() function: format-number(1234.5, '#.##0,00') => '1.234,5' If you want to chop and change between different numerical formats in different parts of the stylesheet, you should create named xsl:decimal-formats for each of the different formats you want to use: <xsl:decimal-format name="German" decimal-separator="," grouping-separator="." /> <xsl:decimal-format name="AltGerman" decimal-separator="," grouping-separator="'" /> <xsl:decimal-format name="US" decimal-separator="." grouping-separator="," /> Then you can use different formats in different places: format-number(1234.5, '#,##0.00', 'US') => '1,234.5' format-number(1234.5, '#.##0,00', 'German') => '1.234,5' format-number(1234.5, "#'##0,00", 'AltGerman') => "1'234,5" Does that enable you to do what you need to do? Or is there something further that you need? Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ 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