Re: [xsl] saxon:try()

Subject: Re: [xsl] saxon:try()
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Fri, 4 Jan 2008 18:29:48 +0100 (CET)
Colin Paul Adams wrote:

> >>>>> "Florent" == Florent Georges <lists@xxxxxxxxxxxx> writes:

> 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.

  I don't think so.  XSLT has the concept of context.  And
the evolution of the dynamic context relies on the lexical

  Whenever the value of a global variable is actually
evaluated, the context is the one corresponding to a global
variable.  For instance:

    <xsl:variable name="v" select="/a" as="element()"/>

    <xsl:template match="/">
             <xsl:for-each select="doc('...')">
                <xsl:copy-of select="$v"/>

  The same way the context node when evaluating $v will
always be the document node of the initial input tree, the
try handler should always be the handler that was in the
context where the variable has been declared.

  At least that is one way to define it.  And in my humble
opinion this is the most natural way (but I tend to often
find natural what I defined myself :-p).

> xsl:variable declares the definition of a value. It
> doesn't indicate execution at all.

  We agree.

> The reference to the variable, which is inside the ex:try,
> is the most logical place to think of the evaluation
> occuring. Or rather, it is the place at which you access
> the value.

  I don't see why this is more logical there.  For me, the
most logical is at one place where it is referenced (from
possibly many).  And only once.  The first one while the
evaluation of the stylesheet.  But all that is about

> If you DIDN'T access the variable within the
> transformation at all, when should the error be raised?
> Prior to the execution of the initial template? That would
> be a bit harsh.

  I don't really see the point.  There no notion of time in
the evaluation of the stylesheet.  And '5.3 says:

    Dynamic errors are reported only if the instructions or
    expressions that cause them are actually evaluated.

  So the error could remain not evaluated, couldn't it?  And
if it is actually evaluated, the transformation should fail
because the error occured outside of an ex:error-safe.

  Thank you for your feedback,


Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail

Current Thread