title: Aggregate-function for sum and product in XPath
body: <p>Similar to this question (http://stackoverflow.com/q/1333558/948404) I want to use XPath to calculate a sum over products in a structure like this:</p>
  
  <pre><code>&lt;items&gt;
      &lt;item&gt;
          &lt;value&gt;1.0&lt;/value&gt;
          &lt;quantity&gt;3&lt;/quantity&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;value&gt;2.5&lt;/value&gt;
          &lt;quantity&gt;2&lt;/quantity&gt;
      &lt;/item&gt;
      &lt;!-- ... --&gt;
  &lt;/items&gt;
  </code></pre>
  
  <p>Is there an XPath expression that calculates the sum of the products of each items <code>value</code> and <code>quantity</code>?</p>
  
  <p><strong>Update:</strong> The solution has to work with PHPs XSLTProcessor class meaning that it probably has to be XSLT 1.0 compliant. This is why I did not yet accept the two probably correct answers using XSLT 2.0. I could neither test them in my PHP implementation nor in my browser nor in the Tryit Editor [1] from w3schools. Sorry!</p>
  
  <ol>
  <li><a href="http://w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&amp;xsltfile=cdcatalog" rel="nofollow">http://w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&amp;xsltfile=cdcatalog</a></li>
  </ol>