format output properties change decimal/thousands separator

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

format output properties change decimal/thousands separator

mabu
Hi,

I want to define the output format properties (e.g. oxf.xforms.format.output.double) so that the decimal separator is "," and the thousands separator is ".".
How can I achive this?

Martin
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

mabu
My "hacky" solution is to use the translate function.

<property as="xs:string"  name="oxf.xforms.format.output.double">
    if (. castable as xs:double) then translate(format-number(xs:double(.),'#,##0.000'),',.','.,') else .
</property>
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

cvesters
Why don't you use the format-number function directly to do the correct formatting?

What you are doing now is converting a number in one format to another.
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

mabu
I want to use the format-number function directly, but I didn't get it working. I tried following: format-number(xs:double(.),'#,##0.000')

Is there somewhere a documentation about the formatting pattern.
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

mabu
Sorry, I had a mistake in my previous post. I tried this function call: format-number(xs:double(.),'#.##0,000')
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

cvesters
My bad, you can not use the format-number for this.
The meaning of '.' and ',' are hardcoded: http://www.w3schools.com/xsl/func_formatnumber.asp

I believe the only way to get around this is as you showed in your original post.
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

mabu
Ok, thank you for the documentation link. I don't get the point that it is a standard xslt function.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: format output properties change decimal/thousands separator

Erik Bruchez
Administrator
Martin,

This means that the `format-number()` function is defined by the XSLT spec:

    https://www.w3.org/TR/xslt20/#function-format-number

It is also part of XPath 3:

    https://www.w3.org/TR/xpath-functions-30/#func-format-number

But it doesn't matter because we also support it from XForms in Orbeon Forms.

-Erik