Project

Profile

Help

using error() and saxon:try() in xquery

Added by Anonymous over 16 years ago

Legacy ID: #4665722 Legacy Poster: James Fuller (cutlass)

I am looking to generalize saxon:try in my xquery code when I declare a wrapper function util:try() declare function util:try($arg1){ saxon:try($arg1,"throw error") }; and invoke util:try(1 div 0) I do not seem to get desired behavior ... e.g. saxon:try(1 div 0, "throw error") thx in advance, Jim Fuller


Replies (1)

RE: using error() and saxon:try() in xquery - Added by Anonymous over 16 years ago

Legacy ID: #4665893 Legacy Poster: Michael Kay (mhkay)

In your example, the offending expression {1 div 0} is executed outside the scope of the saxon:try(), and therefore fails in the normal way. Although Saxon might often do lazy evaluation, the semantics of a function call are that the expressions supplied in the arguments are evaluated, and their values are passed to the called function. So {1 div 0} fails /before/ util:try() is called, or at any rate, in the process of calling util:try(), and long before saxon:try() is called. saxon:try() itself is not actually following the rules; it's best regarded as a pseudofunction, because it influences the way in which its arguments are evaluated. But this stretching of the rules for function calling does not extend to your own util:try() function.

    (1-1/1)

    Please register to reply