title: xslt, calculating sum of sum using function
body: <p>I have client invoices which I calculate price* quantity + total for this colum (for each invoice and each client) using the following function:
      
          Total
              
                   
                       
                  
              
           
      </p>
  
  <pre><code>&lt;xsl:template name="sumProducts"&gt; 
      &lt;xsl:param name="pList"/&gt; 
      &lt;xsl:param name="pRunningTotal" select="0"/&gt;         
      &lt;xsl:choose&gt; 
         &lt;xsl:when test="$pList"&gt; 
             &lt;xsl:variable name="varMapPath" select="$pList[1]"/&gt; 
             &lt;xsl:call-template name="sumProducts"&gt; 
                 &lt;xsl:with-param name="pList" select="$pList[position() &gt; 1]"/&gt; 
                     &lt;xsl:with-param name="pRunningTotal" select="$pRunningTotal + $varMapPath/unitprice *  $varMapPath/quantity"/&gt;                    
             &lt;/xsl:call-template&gt; 
         &lt;/xsl:when&gt; 
         &lt;xsl:otherwise&gt; 
             $&lt;xsl:value-of select="format-number($pRunningTotal, '#,##0.00')"/&gt; 
         &lt;/xsl:otherwise&gt; 
      &lt;/xsl:choose&gt; 
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I would like to calculate the total for all invoices per client and  total invoices for all clients.</p>
  
  <p>Thank you</p>