title: XSLT: Count only when value greater than nul
body: <p>All,</p>
  
  <p>This question is related to XSLT 1.0</p>
  
  <p>Is there a way to only count nodes where a specific value is greater than null?
  I use the sum function to get the total of this:</p>
  
  <pre><code>&lt;servicelevels&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;0..20&lt;/key&gt;
          &lt;value&gt;100.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;20..30&lt;/key&gt;
          &lt;value&gt;0.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;30..40&lt;/key&gt;
          &lt;value&gt;0.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;40..50&lt;/key&gt;
          &lt;value&gt;0.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;50..60&lt;/key&gt;
          &lt;value&gt;0.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;60..70&lt;/key&gt;
          &lt;value&gt;0.00&lt;/value&gt;
      &lt;/servicelevel&gt;
      &lt;servicelevel&gt;
          &lt;key&gt;70+&lt;/key&gt;
          &lt;value&gt;98.33&lt;/value&gt;
      &lt;/servicelevel&gt;
  &lt;/servicelevels&gt;
  </code></pre>
  
  <p>To find the sum of the value keys, I use:</p>
  
  <pre><code>&lt;xsl:value-of select="sum(servicelevels/servicelevel/value | servicelevels/servicelevel/value)"/&gt;
  </code></pre>
  
  <p>what produces the sum of 198.33 to calculate the the average of the 7 nodes I use the <code> xsl:value-of select="count(....)" </code> what calculates it as 28.333 but I only want to find the average for the nodes that contain the actual values what in this example are just 2 nodes what creates an average of 99.165.</p>
  
  <p>Is there another (relative simple) way of achieving this?</p>
  
  <p>The XML always contains the 7 key values</p>