[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] effective boolean value of the result of an extension instruction


Subject: [xsl] effective boolean value of the result of an extension instruction
From: Kevin Rodgers <kevin.rodgers@xxxxxxx>
Date: Mon, 7 Mar 2005 15:25:08 -0700

I'm using Saxon's SQL extension in an XSLT 2.0 stylesheet.  First I set
a variable to the JDBC connection, like this:

      <xsl:variable name="mb3-connection" as="java:java.sql.Connection"
         xmlns:java="http://saxon.sf.net/java-type">
        <xsl:choose>
          <xsl:when test="element-available('sql:connect')">
            <sql:connect driver="{$sql-driver}" database="{$sql-url}"
                         user="{$sql-user}" password="{$sql-password}">
              <xsl:fallback>
                <xsl:message select="'SQL extension is not installed'"
                             terminate="yes"/>
              </xsl:fallback>
            </sql:connect>
          </xsl:when>
          <xsl:otherwise>
            <xsl:message select="'&lt;sql:connect&gt; is not available'"
                         terminate="yes"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>

According to the documentation, the result is a value of type "external
object".  Later, when I reference it in a conditional expression:

  <xsl:value-of select="if ($mb3-connection)
                        then esd:curr-doc-num($mb3-connection, $relation)
                        else $relation"/>

Saxon reports:

  net.sf.saxon.trans.DynamicError: Effective boolean value is not defined for a sequence
  starting with an atomic value other than a boolean, number, or string

Is there a way to test the mb3-connection variable, or do the
<xsl:message terminate="yes"/> instructions in its declaration already
ensure that processing doesn't continue unless it was set successfully?

Thanks,
-- 
Kevin Rodgers


Current Thread
Keywords