# XSLT Error Recovery Policy

Where the XSLT specification requires that an error be signaled, Saxon produces an error message and terminates stylesheet execution. In the case of errors detected at compile time, it attempts to report as many errors as possible before terminating; in the case of run-time errors, it terminates after the first error.

Where the XSLT specification states that the processor may recover from an error, Saxon takes one of three actions as described in the table below. Either it signals the error and terminates execution, or it recovers silently from the error in the manner permitted by the specification, or it places the action under user control. In the latter case there are three options: report the error and terminate, recover silently, or (the default) recover after writing a warning to the system error output stream. These actions can be modified by supplying a user-defined ErrorListener.

Handling of individual recoverable errors is described in the table below.

This list is incomplete and needs to be reviewed.

Error | Action
There is more than one template rule that matches a node, with the same import precedence and priority | User option
There is more that one xsl:namespace-alias statement for a given prefix, with the same import precedence | Recover silently
An element name defined using xsl:element is invalid | User option
An attribute name defined using xsl:attribute is invalid | User option
There are several attribute sets with the same import precedence that define the same named attribute | Recover silently
A processing-instruction name defined using xsl:processing-instruction is invalid | User option
A node other than a text node is written to the result tree while instantiating xsl:attribute, xsl:comment, or xsl:processing-instruction | User option
Invalid characters are written to the content of a comment or processing instruction | User option
An attribute node or namespace node is written directly to the root of a result tree fragment, or to any other node that is not an element node. | User option
A value supplied to the value attribute of xsl:number is negative or non-numeric | User option
The document() function identifies a resource that cannot be retrieved | User option
There are several xsl:output elements specifying the same attribute with the same import precedence | Recover silently
disable-output-escaping is used for a text node while instantiating xsl:attribute, xsl:comment, or xsl:processing-instruction | Recover silently
disable-output-escaping is used for a text node within a result tree fragment that is subsequently converted to a string or number | Recover silently
disable-output-escaping is used for a text node containing a character that cannot be output using the target encoding | Recover silently

Expand |