Use format-number(12345, "0000000000") .
This obviously only works for numbers, and can only process zeros, but you can use any character using the following substring:
concat(substring('0000000000',string-length($val)),$val)
This can be useful when filling in with .... or spaces, for example, or if your value is not numeric.
source share