title: How do I test if a parameter has been passed into a template in XSLT v 2.0?
body: <p>I'm currently trying to upgrade from XSLT 1.0 to XSLT 2.0. I had the following in one of my templates that used to work with XSLT 1.0 :- </p>
  
  <pre><code>&lt;xsl:template name="some_t"&gt;
    &lt;xsl:param name="some_numeric_param"/&gt;
    &lt;xsl:if test="$some_numeric_param != ''"&gt;
      &lt;xsl:attribute name="some_name"&gt;
        &lt;xsl:value-of select="$some_numeric_param"/&gt;
      &lt;/xsl:attribute&gt;
    &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Now, there are three cases in which I call this template :- </p>
  
  <pre><code>&lt;xsl:call-template name="some_t"&gt;
    &lt;xsl:with-param name="some_numeric_param" select="floor(number(./@attr1) div 20)"/&gt;
  &lt;/xsl:call-template&gt;
  </code></pre>
  
  <p>When I do this, basically the inner template will only create the attribute called "some_name" iff the attribute called "attr1" is given in the source document.</p>
  
  <p>Also, another situation in which I might call this is without this param :- </p>
  
  <pre><code>&lt;xsl:call-template name="some_t"&gt;
  &lt;/xsl:call-template&gt;
  </code></pre>
  
  <p>So What I basically want it to do is that when I pass in a parameter then create an attribute, otherwise don't. Whether my stylesheet is correct or not, this worked in XSLT 1.0 but in XSLT 2.0 it gives an error that says :-</p>
  
  <pre><code>Error on line 195 of movwin.xsl:
    XPTY0004: Cannot compare xs:double to xs:string
  Transformation failed: Run-time errors were reported
  </code></pre>
  
  <p>Any help? I'm using the Saxon 9.4 processor.</p>