[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: effective boolean value of the result of an extens

Subject: RE: effective boolean value of the result of an extension instruction
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 7 Mar 2005 22:43:19 -0000
sql boolean
The <xsl:variable> is either going to give you a run-time error, or it's
going to set the variable to a value of type java:java.sql.Connection.

The xsl:fallback gives fallback behavior if the sql:connect instruction
isn't recognized. If you want to handle a failure reported by the JDBC
database connection, you'll have to use saxon:try() (which is a Saxon-SA
extension function). Alternatively you could of course modify the
sql:connect source code - it's only really intended as a specimen
implementation.

Michael Kay
Saxonica Limited 

> -----Original Message-----
> From: Kevin Rodgers [mailto:kevin.rodgers@xxxxxxx] 
> Sent: 07 March 2005 22:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  effective boolean value of the result of an 
> extension instruction
> 
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.