title: XSLT 2.0 Sum of values considered as string
body: <p>I am confronted to what I thought it was a simple problem but I am stuck.
  Here is an xml data</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;report endDate="2013/02/01 15:10:14" environment="Q000" startDate="2013/01/25 15:10:14"&gt;
  &lt;distrib appCode="LI" busLine="IL" context="" id="2013-01-25-15.10.11.785293" network="FBB" subNetwork="Z"&gt;
    &lt;deliv id="2013-01-25-15.10.11.785295" mode="1" role=""&gt;
       &lt;comm id="2013-01-25-15.10.11.785297" role=""&gt;
          &lt;group id="001"&gt;
             &lt;doc id="950955269" nbPages="1" templateId="LVMED1" /&gt;
          &lt;/group&gt;
          &lt;group id="002"&gt;
             &lt;doc id="950955270" nbPages="6" templateId="BALVANW_FA" /&gt;
          &lt;/group&gt;
          &lt;group id="003"&gt;
             &lt;doc id="950955271" nbPages="" templateId="LVMED23" /&gt;
          &lt;/group&gt;
       &lt;/comm&gt;
    &lt;/deliv&gt;
  &lt;/distrib&gt;
  &lt;distrib appCode="LI" busLine="IL" context="" id="2013-01-25-15.18.29.871466" network="FBB" subNetwork="Z"&gt;
    &lt;deliv id="2013-01-25-15.18.29.871468" mode="1" role=""&gt;
       &lt;comm id="2013-01-25-15.18.29.871469" role=""&gt;
          &lt;group id="001"&gt;
             &lt;doc id="950955331" nbPages="2" templateId="LVMED10" /&gt;
          &lt;/group&gt;
       &lt;/comm&gt;
    &lt;/deliv&gt;
  &lt;/distrib&gt;
  &lt;/report&gt;
  </code></pre>
  
  <p>I would like to sum the content of attributes nbPages in elements 'doc'</p>
  
  <p>Here is the xslt I use:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xs"
  version="2.0"&gt;
  &lt;xsl:output method="text" /&gt;
  
  &lt;xsl:template match="report"&gt;
    &lt;xsl:value-of select="count(//doc)"/&gt;
    &lt;xsl:value-of select="sum(//doc[@nbPages])"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The count works well, but the sum does not.</p>
  
  <p><strong>[Saxon-PE 9.3.0.5] Cannot convert string {} to a double</strong></p>
  
  <p>I have tried using the following alternatives without success:</p>
  
  <pre><code>&lt;xsl:value-of select="sum(number(//doc[@nbPages]))"/&gt;
  &lt;xsl:value-of select="sum(//doc[number(@nbPages)])"/&gt;
  </code></pre>
  
  <p>Any help would be very appreciated on this.</p>