Padding number with leading zeros in XSLT 1.0

Another approach is

substring(string(1000000000000000 + $x), 2)

I need to pad this with leading zeros to a length of 15 in the output (

That would be

substring(
  concat('000000000000000', msg:BankAccount/msg:Counter), 
  string-length(msg:BankAccount/msg:Counter) + 1, 
  15
)

It can be also done using string-format

<xsl:value-of select="format-number(msg:BankAccount/msg:Counter, '000000000000000')" />

in general:

<xsl:value-of select="format-number(number_you_would_like_to_padd, 'string_how_much_zeros_you_would like')" />