title: How to sum variables in xslt
body: <p>I'm new in XSLT, and I'm having problems to solve this. I have some values that aren't in the XML document, so I need to create them, like this:</p>
  
  <pre><code>   &lt;xsl:for-each select="msxsl:node-set($obsData)/Round"&gt;
      &lt;xsl:with-param name="Save1"&gt;
         &lt;xsl:variable name="xx"&gt;
          &lt;xsl:element name="lasuma"&gt;
           &lt;xsl:value-of select="(some calculation)"/&gt;
          &lt;/xsl:element&gt;
         &lt;/xsl:variable&gt;  
         &lt;xsl:value-of select="msxsl:node-set($xx)/lasuma"/&gt; 
      &lt;/xsl:with-param&gt;
     &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>So now that I have the values that I need, I save them into the variable. Now I need to sum it, but the only way that the function SUM seems to works is when you have nodes, and I can't sum the values in a variable. I tried this, but it doesn't sum the values that I specified in that path:</p>
  
  <p>..."sum(msxsl:node-set($xx)/lasuma)"/></p>
  
  <p>Is there a way to sum the values in a variable? A simple example that I might follow, would be much appreciated. Thanks.</p>