XQuery try/catch expressions

This topic describes how XQuery try/catch is implemented in XQuery for Endeca.

The Endeca XQuery implementation supports the try/catch facility specified in XQuery 1.1 Working Draft 3 (http://www.w3.org/TR/xquery-11). Try/catch expressions provide a mechanism for handling errors raised during the evaluation of an XQuery main module.

Try/catch simplifies the development of Web services in XQuery by enabling the author to handle application errors appropriately in the service. For example, an XQuery main module implementing a SOAP Web service might contain an outermost try/catch to intercept any errors raised during evaluation of the service and produce a response containing an appropriate SOAP Fault.

Errors that are unhandled by a service, and thus escape the XQuery evaluator, are treated as follows:

The interaction of XQuery try/catch expressions with updating expressions

When try/catch expressions are used with the Endeca implementation of XQuery update, if exceptions are raised in a try block, any updates appended within that try block are removed from the pending update list. This rollback is applied regardless of whether the exception is caught at that point, caught further up the stream, or escapes the program.