title: How to sum different fields in XSL when some might be null?
body: <p>I have the following XSL :</p>
  
  <pre><code>    &lt;xsl:value-of select='translate(format-number(
          Gaz/Baf/CH4
          + Gaz/Std/CH4
          + Gaz/Bsa/CH4
          + Gaz/Bbs/CH4
          + Gaz/Bhf/CH4
          + Gaz/Bin/CH4
          , "### ### ### ##0.######"),".",",")' /&gt;
  </code></pre>
  
  <p>The sum adds up nicely when all my items have values. However, if one of them is null (<code>&lt;CH4 xsi:nil="true"/&gt;</code>), then my sums become <code>NaN</code>. </p>
  
  <p>So far I tried adding a new function. But it's not supported by the pdf generator we use. (<em>System.Xml.Xsl.XslLoadException: 'xsl:function' is still not implemented</em>)</p>
  
  <p>I tried adding a C# function to add as an <em>XsltArgumentList</em>. A simple <code>return value ?? 0;</code> But I also get an exception : _System.Xml.Xsl.XslTransformException: Params or values of an extention function with a Clr 'Nullable`1' type are not managed _</p>
  
  <p>And now I'm trying to use a <code>xsl:variable</code>, but I find no example where they add value to the variable (Is a variable static once defined?)</p>
  
  <p>So, any suggestions?</p>