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

Re: ex:error-safe (was: saxon:try())

Subject: Re: ex:error-safe (was: saxon:try())
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Wed, 9 Jan 2008 18:54:48 +0100 (CET)
Re:  ex:error-safe (was: saxon:try())
Colin Adams wrote:

  Hi

> > >   If you want to prevent the global variable
> > > evaluation to throw an error, use something like this:

> > > <xsl:variable name="v" as="node()"/>
> > >    <ex:error-safe>
> > >       <ex:try>
> > >          <xsl:sequence select="error()"/>
> > >       </ex:try>
> > >       <ex:catch>
> > >          <xsl:sequence select="'alternative value'"/>
> > >       </ex:catch>
> > >    </ex:error-safe>
> > > </xsl:variable>

> The problem with this is that, in general, you don't know
> whether or not it is right to catch the error. The
> accessor of the variable might be in a different module,
> by a different author.

> You won't always be able to guess what is best for the
> user of the module.

  I think we have just different points of view.

  IMHO, a global variable declaration defines a value.
Either the value can be defined using some try/catch
mecanism (for instance providing () in case of error),
either the transform should fail in case of error while
evaluating the value.

  If this is not possible, and the variable writer want to
let the user the chance to catch the error, it should
instead use a function.

  I know that a function with now argument could be view as
a global variable in a functional language without
side-effects.  The difference here occurs only on regard of
the error handling, because of this error handling is
defined (differently for variables and functions).

  I don't think this is really confusing: the error context
while evaluating a variable value is the error context where
the variable is declared, and for functions it is the error
context of the function call.

  I think this is even quite intuitive (it seems just we
don't have the same intuition on this :-p):

    <xsl:variable name="v" select="error()"/>

    <xsl:function name="my:f">
       <xsl:sequence select="error()"/>
    </xsl:function>

    <xsl:template match="/">
       <ex:error-safe>
          <ex:try>
             <xsl:sequence select="$v, my:f()"/>
          </ex:try>
          <ex:catch/>
       </ex:error-safe>
    </xsl:template>

  IMHO the error of evaluating $v should not be caught,
while the error of evaluating my:f() should.

  Regards,

--drkm

























      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr

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.