title: Padding number with leading zeros in XSLT 1.0
body: <p>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 for loading into another system.</p>
  
  <p>I need to pad this with leading zeros to a length of 15 in the output (which is fixed length text)</p>
  
  <p>Examples: </p>
  
  <pre><code> - 1 becomes   000000000000001
   - 11 becomes  000000000000011
   - 250 becomes 000000000000250
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>&lt;xsl:value-of select="substring(concat('000000000000000', msg:BankAccount/msg:Counter), 12, 15)"/&gt;
  </code></pre>
  
  <p>to get the 15 zeros at the beginning and take the substring but I must have made a mistake with the substring because in the results I get </p>
  
  <pre><code>0000000000000000000000009LLOYDS BANK PLC
  00000000000000000000000010LLOYDS BANK PLC
  </code></pre>
  
  <p>I also tried <code>format-number</code> but I it returns NaN</p>
  
  <pre><code>&lt;xsl:value-of select="format-number(msg:BankAccount/msg:Counter, '000000000000000')"/&gt;
  </code></pre>
  
  <p>returns 'NaN'</p>
  
  <p>so what have I done wrong and what is the best way to do this?</p>