title: Problem summing a total in XSLT Template
body: <p>I am having a problem trying to simply sum some values using XSLT. I a template online and have modified it for my needs. (<a href="http://blog.davidkaspar.com/archives/2003/10/xslt-sum-of-products-from-multiple-nodes.php" rel="nofollow noreferrer">link text</a>)</p>
  
  <p>No matter how I try, I cannot get the template to sum the numbers. I either end up with a total of "0" or a concatenation of the numbers I want summed. If someone could take a look and point out where I am going wrong, I would greatly appreciated it.</p>
  
  <p>Thanks </p>
  
  <p>** TEMPLATE ** </p>
  
  <pre><code>print("&lt;xsl:template match="Parts"&gt;
      &lt;root&gt;
          &lt;xsl:variable name="tmpTotal"&gt;
              &lt;total_amount&gt;
                  &lt;xsl:for-each select="Part"&gt;
                      &lt;item&gt;
                          &lt;xsl:value-of select="Duration"/&gt;
                      &lt;/item&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/total_amount&gt;
          &lt;/xsl:variable&gt;
          &lt;total&gt;
              &lt;xsl:variable name="myTotal" select="number(msxsl:node-set($tmpTotal))" /&gt; &lt;!--Shows up as 0--&gt;
              &lt;xsl:value-of select="sum(msxsl:node-set($myTotal)/total_amount/item)" /&gt;
              &lt;!--&lt;xsl:variable name="myTotal" select="msxsl:node-set($tmpTotal)" /&gt;--&gt; &lt;!-- Shows up as concatenation--&gt;
              &lt;!--&lt;xsl:value-of select="msxsl:node-set($myTotal)" /&gt;--&gt; 
          &lt;/total&gt;
      &lt;/root&gt;
  &lt;/xsl:template&gt;");
  </code></pre>
  
  <p>** XML **</p>
  
  <pre><code>print("&lt;Parts&gt;
  &lt;Part&gt;
    &lt;PartNum&gt;0000-A123&lt;/PartNum&gt; 
    &lt;Rate&gt;0&lt;/Rate&gt; 
    &lt;Rate0Decimal&gt;0&lt;/Rate0Decimal&gt; 
    &lt;ProductRemovedNumber&gt;...&lt;/ProductRemovedNumber&gt; 
    &lt;Qty&gt;2&lt;/Qty&gt; 
    &lt;Resolution&gt;False&lt;/Resolution&gt; 
    &lt;ReturnFA&gt;False&lt;/ReturnFA&gt; 
    &lt;SerialNumber /&gt; 
    &lt;TickProblemCD&gt;15&lt;/TickProblemCD&gt; 
    &lt;TicketNum&gt;075020009000048&lt;/TicketNum&gt; 
    &lt;Total&gt;0&lt;/Total&gt; 
    &lt;Total0Decimal&gt;0&lt;/Total0Decimal&gt; 
    &lt;TotalDisplay&gt;0&lt;/TotalDisplay&gt; 
    &lt;UserNumber&gt;009&lt;/UserNumber&gt; 
    &lt;/Part&gt;
  &lt;Part&gt;
    &lt;Duration&gt;2&lt;/Duration&gt;
    &lt;Total&gt;0&lt;/Total&gt; 
    &lt;PartCost&gt;0.00&lt;/PartCost&gt; 
    &lt;PartCost0Decimal&gt;0&lt;/PartCost0Decimal&gt; 
    &lt;PerformedBy&gt;TEST&lt;/PerformedBy&gt; 
    &lt;WorkDoneCode /&gt; 
    &lt;WorkDoneDesc /&gt; 
    &lt;ZoneBasedTravel&gt;False&lt;/ZoneBasedTravel&gt; 
    &lt;PartNum&gt;Travel&lt;/PartNum&gt; 
    &lt;PartDescr&gt;---&lt;/PartDescr&gt; 
    &lt;Qty&gt;2&lt;/Qty&gt; 
    &lt;/Part&gt;
  &lt;Part&gt;
    &lt;Duration&gt;4&lt;/Duration&gt; 
    &lt;DurationRequired&gt;True&lt;/DurationRequired&gt; 
    &lt;EndTime&gt;12/4/2008 2:24 PM&lt;/EndTime&gt; 
    &lt;EndTimeOnly&gt;12/4/2008&lt;/EndTimeOnly&gt; 
    &lt;FamilyName&gt;NON-COMPLAINT&lt;/FamilyName&gt; 
    &lt;FOC&gt;False&lt;/FOC&gt; 
    &lt;InvTxnGenerated /&gt; 
    &lt;LastUpdatedDate&gt;12/4/2008 2:24 PM&lt;/LastUpdatedDate&gt; 
    &lt;Rate&gt;0&lt;/Rate&gt; 
    &lt;Rate0Decimal&gt;0&lt;/Rate0Decimal&gt; 
    &lt;RateType&gt;Install&lt;/RateType&gt; 
    &lt;Total&gt;0&lt;/Total&gt; 
    &lt;PartCost&gt;0.00&lt;/PartCost&gt; 
    &lt;PartCost0Decimal&gt;0&lt;/PartCost0Decimal&gt; 
    &lt;PerformedBy&gt;TEST&lt;/PerformedBy&gt; 
    &lt;WorkDoneCode&gt;17000&lt;/WorkDoneCode&gt; 
    &lt;WorkDoneDesc&gt;De-Installation / Instrument Move&lt;/WorkDoneDesc&gt; 
    &lt;ZoneBasedTravel&gt;False&lt;/ZoneBasedTravel&gt; 
    &lt;PartNum&gt;Labor&lt;/PartNum&gt; 
    &lt;PartDescr&gt;Install&lt;/PartDescr&gt; 
    &lt;Qty&gt;4&lt;/Qty&gt; 
    &lt;/Part&gt;
  &lt;Part&gt;
    &lt;Duration&gt;1&lt;/Duration&gt; 
    &lt;DurationRequired&gt;True&lt;/DurationRequired&gt; 
    &lt;EndTime&gt;12/4/2008 2:24 PM&lt;/EndTime&gt; 
    &lt;EndTimeOnly&gt;12/4/2008&lt;/EndTimeOnly&gt; 
    &lt;FamilyName&gt;NON-COMPLAINT&lt;/FamilyName&gt; 
    &lt;FOC&gt;False&lt;/FOC&gt; 
    &lt;InvTxnGenerated /&gt; 
    &lt;LastUpdatedDate&gt;12/4/2008 2:24 PM&lt;/LastUpdatedDate&gt; 
    &lt;Rate&gt;0&lt;/Rate&gt; 
    &lt;Rate0Decimal&gt;0&lt;/Rate0Decimal&gt; 
    &lt;RateType&gt;TSB/ISA&lt;/RateType&gt; 
    &lt;Total&gt;0&lt;/Total&gt; 
    &lt;PartCost&gt;0.00&lt;/PartCost&gt; 
    &lt;PartCost0Decimal&gt;0&lt;/PartCost0Decimal&gt; 
    &lt;PerformedBy&gt;TEST&lt;/PerformedBy&gt; 
    &lt;WorkDoneCode&gt;13000&lt;/WorkDoneCode&gt; 
    &lt;WorkDoneDesc&gt;TSB / ISA - Installed&lt;/WorkDoneDesc&gt; 
    &lt;ZoneBasedTravel&gt;False&lt;/ZoneBasedTravel&gt; 
    &lt;PartNum&gt;Labor&lt;/PartNum&gt; 
    &lt;PartDescr&gt;TSB/ISA&lt;/PartDescr&gt; 
    &lt;Qty&gt;1&lt;/Qty&gt; 
    &lt;/Part&gt;
    &lt;/Parts&gt;");
  </code></pre>