Search code examples
xsltxslt-1.0xslt-2.0xslt-groupingxslt-3.0

Right padding a String with Zeros in XSLT


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

Examples:

A becomes A00

AB becomes AB0

ABC becomes ABC

Please help.


Solution

  • You could do simply:

    substring(concat($your-string, '000'), 1, 3)
    

    Note that this means that "ABCD" becomes "ABC".