Maash
Maash

Reputation: 31

Adding leading zeroes to record in xslt

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:

Please help.

Upvotes: 3

Views: 4814

Answers (1)

Michael Kay
Michael Kay

Reputation: 163342

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

Upvotes: 7

Related Questions