title: Formatting numbers before taking Sum in XSL sheet
body: <p>Here is My XML:</p>
  
  <pre><code>&lt;OutboundPaymentInstruction&gt;
    &lt;OutboundPayment&gt;
     &lt;Extend2&gt;
        &lt;SHOW_CONVERTED_AMOUNT&gt;Y&lt;/SHOW_CONVERTED_AMOUNT&gt;
        &lt;BASE_AMOUNT&gt;2150.1435&lt;/BASE_AMOUNT&gt;
      &lt;/Extend2&gt;
    &lt;/OutboundPayment&gt;
    &lt;OutboundPayment&gt;
      &lt;Extend2&gt;
        &lt;SHOW_CONVERTED_AMOUNT&gt;Y&lt;/SHOW_CONVERTED_AMOUNT&gt;
        &lt;BASE_AMOUNT&gt;8258.4375&lt;/BASE_AMOUNT&gt;
      &lt;/Extend2&gt;
    &lt;/OutboundPayment&gt;
    &lt;OutboundPayment&gt;
      &lt;Extend2&gt;
        &lt;SHOW_CONVERTED_AMOUNT&gt;Y&lt;/SHOW_CONVERTED_AMOUNT&gt;
        &lt;BASE_AMOUNT&gt;4085.1105&lt;/BASE_AMOUNT&gt;
      &lt;/Extend2&gt;
    &lt;/OutboundPayment&gt;
   &lt;/OutboundPaymentInstruction&gt;
  </code></pre>
  
  <p>This is the XSL:</p>
  
  <pre><code>&lt;xsl:template match="OutboundPaymentInstruction"&gt;
    &lt;Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;GrpHdr&gt;
        &lt;CtrlSum&gt;
          &lt;xsl:if test="(/OutboundPaymentInstruction/OutboundPayment/Extend2/SHOW_CONVERTED_AMOUNT='Y')"&gt;
            &lt;xsl:value-of select="sum(format-number(/OutboundPaymentInstruction/OutboundPayment/Extend2/BASE_AMOUNT,'#.00'))"&gt;&lt;/xsl:value-of&gt;
          &lt;/xsl:if&gt;
        &lt;/CtrlSum&gt;
      &lt;/GrpHdr&gt;
    &lt;/Document&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I want format the numbers to 2 decimal before taking the sum in XSL. For instance I want to add 2150.14,8258.43 and 4085.11 rather then their 4 decimal format.Is it possible to convert them to 2 decimal and then take their sum.Please help</p>
  
  <hr>
  
  <p><strong>Added:</strong></p>
  
  <p>This XSL was developed by someone else and later they found one bug and thats why asked me to work on this. Clearly I don't know anything about XML or XSL. Now the issue was, suppose if input amounts are 45.678 and 23.456, but in XSL we were truncating these amounts to 2 decimals and sendting to bank as 45.67 and 23.45 alongwith their sum(69.13). Now Bank is adding the individual amounts(69.12) and comparing it with the given sum(69.13). Thats why I want to format the numbers before adding them rather then after the sum.</p>