RE: [xsl] saxon:try()

Subject: RE: [xsl] saxon:try()
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 4 Jan 2008 14:59:50 -0000
>     Florent>   But I think that the ex:error-safe instruction should
>     Florent> be exactly predictable, deterministic.  If an expression
>     Florent> stands lexically outside of the instruction, if it
>     Florent> produces an exception, it shouldn't be caught (but that's
>     Florent> only my humble point of view).
> 
> But that goes against the declarative nature of XSLT.
> 
> xsl:variable declares the definition of a value. It doesn't 
> indicate execution at all.
> 
> The reference to the variable, which is inside the ex:try, is 
> the most logical place to think of the evaluation occuring.

You can do it that way - treating a variable reference rather like a
function call - but it gets difficult if one reference to a variable is
inside a try/catch and another isn't (or is in a different try/catch). Do
you catch the error twice? 

I think it's easier to use the more conventional model where the variable is
treated as if it is eagerly evaluated. That doesn't actually stop lazy
evaluation internally - you just have to make the try/catch environment of
an expression part of the closure that you retain until the evaluation is
performed, just as you retain the other parts of its context already.

Michael Kay
http://www.saxonica.com/

Current Thread