Search code examples
xpathtibco-business-works

How to format a number with XPath in Tibco BW 5


I've managed to format the following lines in XPath, from this format:

1000.50
30

to this:

100050
3000

The solution I've adopted is:

concat(substring-before([number], '.'), substring-after([number], '.'))

If the . is not present I directly multiply the number by 100.

I'm wondering if there is any better way to do that. My second thought was using Java.


Solution

  • What goes wrong if you just multiply by 100? So long as the result of multiplying by 100 is an exact integer, it should be formatted without a "." when converted to a string. If there are rounding errors that mean the result is not an exact integer, you might want to use round().

    The concat() approach seems fragile to me: what if someone gives you input like 1000.5 or perhaps 1000.500?