Problem with format-number 'converting string'

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

Problem with format-number 'converting string'

ChrisSpeare
Trying to use format-number in a calculation to format a number to 4dp, however the function is complaining:

XForms error: Cannot convert string "3,619.6328" to a double

The setvalue is:

<xforms:setvalue ref="instance('instance')/value3" value="format-number(xs:decimal('3619.632755555'), '###,##0.0000')"/>

Full xhtml to run in sandbox is here test.xhtml

Stick any number in the first box, then any number in the second and move out.

Any reason why, even though I ask for a decimal type, does this read as a string?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with format-number 'converting string'

Erik Bruchez
Administrator
Chris,

I don't think that's a bug.

When I enter a value in the second xforms:input field,
you are storing into value3 a formatted value which contains commas
(like the example you provide, "3,619.6328").

Then your first xforms:output passes this value to the format-number
function, which expects a numeric value as first argument. "3,619.6328"
is not a numeric value because it contains this funny comma, hence the
error.

-Erik

ChrisSpeare wrote:

> Trying to use format-number in a calculation to format a number to 4dp,
> however the function is complaining:
>
> XForms error: Cannot convert string "3,619.6328" to a double
>
> The setvalue is:
>
> <xforms:setvalue ref="instance('instance')/value3"
> value="format-number(xs:decimal('3619.632755555'), '###,##0.0000')"/>
>
> Full xhtml to run in sandbox is here
> http://www.nabble.com/file/p11516148/test.xhtml test.xhtml
>
> Stick any number in the first box, then any number in the second and move
> out.
>
> Any reason why, even though I ask for a decimal type, does this read as a
> string?
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws