3

We have a number in XML that can go up to 3 digits in a large XML file that has to be converted to fixed length text using xslt for loading into another system.

I need to pad this with leading zeros to a length of 3 in the output (which is fixed length text)

Examples:

  • 1 becomes 001
  • 11 becomes 011
  • 250 becomes 250

Please help.

Maash
  • 31
  • 1
  • 5

1 Answers1

7

format-number($n, '000') should do the trick. Alternatively, substring(string(1000+$n), 2).

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thanks for that alternative. Our runtime environment doesn't make format-number() visible, so the alternative was a godsend. – PKCLsoft Dec 07 '17 at 22:13