Search code examples
orbeon

Orbeon: format number in template parameter


I am working on an Orbeon form where the user needs to confirm the values of some input fields before being allowed to send in the form. The confirmation uses single checkboxes to allow different error messages.

The number formatting throughout the form is with comma as decimal separator and point as thousands separator.

Now, when I add the needed cell names as template parameters to a label to a single checkbox, the number from the cell is shown with point as decimal separator and no thousands separator, even though it is shown correctly in the original field and in the pdf?

So, how can I change this formatting of the number in a template parameter?

I tried format-number(//cell,"99.999,00") in the template parameter.

I also tried converting the number to a string and replace the point with a comma. It just seems like there must be a simpler solution


Solution

  • Try the following, replacing $number with the reference to the value you want to display.

    translate(
        format-number(xs:decimal($number),'#,##0.00'),
        ',.',
        '.,'
    )
    

    Credit: OP suggested technique using translate().