0

The mission here is to output the final value in 5 decimal places, even if the decimals stop < 5 places, '0' is to be concatenated to it.

For example,

x = '7.317' -> '7.31700';

x = '8.14' -> '8.14000';

x = '1.2' -> '1.20000';

x = '1' -> '1.00000';

I understand using fn:format-number() can resolve the matter, but is there an alternative to it?

I've tried the following,

1) y = concat(x, "100000");

2) substring(y, string-length(x) + 1, 5);

The result isn't promising though.

Checking through online, I notice some used string-length(for $i ...), didn't quite understand this part.

Can the community please assist me on this.

Thank you.

Community
  • 1
  • 1
Vincent
  • 209
  • 2
  • 9
  • http://stackoverflow.com/questions/25662151/padding-number-with-leading-zeros-in-xslt-1-0 https://saxonica.plan.io/boards/3/topics/2083 https://saxonica.plan.io/boards/3/topics/2083 The above are the few links that I've referred to and applied, but to no avail yet. – Vincent Nov 15 '16 at 08:59
  • 1) Wouldn't you want `y = concat(x, "00000");`? And you should get the substring which ends five characters after the "." - or add a ".00000" if there isn't a "." in it. 2) This would probably be easier to do in the presentation layer. – Andrew Morton Nov 15 '16 at 09:04
  • @Vincent Please let me know if (and explain how) the linked dupe doesn't solve your problem. – har07 Nov 15 '16 at 09:06

0 Answers0