RE: [xsl] Coding aroung a "Cannot convert zero-length string to an integer" error

Subject: RE: [xsl] Coding aroung a "Cannot convert zero-length string to an integer" error
From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Aug 2007 14:15:53 -0500
> Andrew Welch
>So basically always type your parameters - if you're expecting a string
that can be empty then you want:
><xsl:param name="foo" as="xs:string?"/>
>...and then using test="not($foo)" should be fine.

In the function below, I've typed my $xpath, but still the empty string
was passed to saxon:evaluate and generated the 'Expected node but
received EOF' message from Saxon.  When I changed it to check for
string-length, I received my custom error message.

Did I miss something?


  <xsl:function name="fk:eval">
    <xsl:param name="context" as="node()+"/>
    <xsl:param name="xpath" as="xs:string" />
    <xsl:param name="msg" as="xs:string" />

   <xsl:choose>
      <!-- <xsl:when test="not($xpath)"> -->
      <xsl:when test="string-length(normalize-space($xpath)) eq 0">
        <xsl:text> Custom error message. </xsl:text>
      </xsl:when>
      <!-- More code removed -->
      <xsl:otherwise>
        <xsl:sequence select="$context/sax:evaluate($xpath)" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:function>


Thanks!
Angela

Current Thread