title: Using sum() on context node based on attribute values
body: <p>I have an XML file and part of the node tree is as the following...
  <img src="https://i.stack.imgur.com/I7kIb.png" alt="enter image description here"></p>
  
  <p>I have a template for the par node and within it I must sum the par elements between a range of holeNumbers, the following is part of my code but it isn't working at all and I'm not sure how to reference and sum the par elements based on the attribute values (the sum of the hole values 10-18 should be summed under the in column in the table below)...</p>
  
  <pre><code>&lt;xsl:when test="@holeNumber = 18"&gt;
     &lt;td class="sub"&gt;&lt;xsl:value-of select="sum(.[@holeNumber &gt; 9 and @holeNumber 
                                                               &amp;lt; 18])" /&gt;&lt;/td&gt;
     &lt;td class="final"&gt;&lt;xsl:value-of select="sum(//par)" /&gt;&lt;/td&gt;
  &lt;/xsl:when&gt;
  </code></pre>
  
  <p>My table currently looks as the following...</p>
  
  <pre><code>hole |1 |2 |3 |4 |5 |6 |7 |8 |9 | out |10 |11 |12 |13 |14 |15 |16 |17 |18 | in
       |4 |4 |5 |3 |4 |4 |5 |3 |4 |     |4  |5  |4  |3  |4  |5  |4  |3  |4  |
  </code></pre>