title: Numeric variable/parameter in XSLT
body: <p>I have this XSLT:</p>
  
  <pre><code>&lt;xsl:template match="/"&gt;
  
      &lt;xsl:variable name="errorCount" select="count($orders/*[1]/cm:Error)" /&gt;
  
      &lt;xsl:apply-templates select="@*|node()"&gt;
          &lt;xsl:with-param name="errorCount" select="$errorCount" tunnel="yes" /&gt;
      &lt;/xsl:apply-templates&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="status"&gt;
      &lt;xsl:param name="errorCount" tunnel="yes" /&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="$errorCount &gt; 0"&gt;
                  &lt;xsl:text&gt;ERROR&lt;/xsl:text&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:text&gt;OK&lt;/xsl:text&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The tunneling and all seems to work, but the transformation fails with the following error:</p>
  
  <blockquote>
    <p>Required item type of first operand of '>' is numeric; supplied value has item type xs:string</p>
  </blockquote>
  
  <p>I first had the variable declaration in the template where it is it used, and then it worked fine. Moved it because I need to use the same count in other templates too.</p>
  
  <p>How/Where do I declare that this variable/parameter is in fact a number?</p>