On 23/01/2012 20:42, Jaroslav Brazda wrote:


I tried to use try/catch expression as it is described in XQuery 3.0 specification




Saxon documentation indicates that it should support such constructs,


Actually, that page is describing a propietary XSLT extension saxon:try/saxon:catch, which predated the introduction of try/catch into XQuery 3.0 and XSLT 3.0.

The current state of support for XQuery try/catch in Saxon 9.3 is documented here:


and for Saxon 9.4 here:


However, I think there is probably an omission here: It looks to me as if the implicitly declared variables such as $err:code are not yet implemented.

Michael Kay


I’m getting following error when I try to run code listed below

Try/catch block itself works but I need to get access to error information to generate formated error message in my library module. How can I access error information inside catch block

Error on line 12 column 14 of expression-test.xq:

  XPST0008 XQuery static error near #...) } catch * { $err:code, $#:

    Variable $err:code has not been declared

Static error(s) in query



    Saxon try/catch support test


xquery version "3.0";


declare namespace err = 'http://www.w3.org/2005/xqt-errors';

try {

    fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000'))


catch * {

    $err:code, $err:value, " module: ", $err:module, "(", $err:line-number, ",", $err:column-number, ")"




Jaroslav Brazda

Senior Consulting Architect

Email: jaroslav.brazda@activevos.com

Cell: 617-335-6991


Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!

saxon-help mailing list archived at http://saxon.markmail.org/