title: XSL 1.0 Summing values with £, " and , in whist using a key
body: <p>I am trying to sum the following costs grouped by a unique field called ID</p>
  
  <p>The xml is as follows:</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;"£20,000.00"&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;"£1,000.00"&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;"-£2,000.00"&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;"£2,000.00"&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;"£1,000.00"&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have produced the following which keeps returning NAN due to the non numeric characters.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet  version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="text" version="1.0" encoding="UTF-8"/&gt;
  &lt;xsl:key name="UniqueJobNumber" match="table/tr" use="td[01]"/&gt;
  &lt;xsl:template match="table"&gt;
      &lt;xsl:for-each select="tr[(count(. | key('UniqueJobNumber', td[01])[1]) = 1)]"&gt;
          &lt;xsl:variable name= "PaymentRequestValue" select="sum(key('UniqueJobNumber',td[01])/td[02])"/&gt;
          &lt;xsl:value-of select="td[01]"/&gt;
          &lt;xsl:text&gt;,&lt;/xsl:text&gt;
          &lt;xsl:value-of select="$PaymentRequestValue"/&gt;
          &lt;xsl:text&gt;&amp;#13;&lt;/xsl:text&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>Does anyone know a way of removing the £, and " characters from the field to make the sum work?  I have tried using translate functions within the variable used to calculate the value but that doesn't seem to work.</p>
  
  <p>Cheers,</p>
  
  <p>Matt</p>