The saxon:try instruction evaluates an XPath expression in its select
attribute, or a sequence of child instructions. If any dynamic error occurs while performing this
evaluation, the error may be caught by an xsl:catch instruction that is written as a child
of the xsl:try. For example, the following code catches a failure occurring while executing the
document() function, and returns an <error-document/> element if this
occurs.
<xsl:variable name="doc" as="document-node()">
<saxon:try select="document($input-uri)">
<saxon:catch errors="*">
<xsl:document>
<error-document/>
</xsl:document>
</saxon:catch>
</saxon:try>
</xsl:variable>The saxon:try element must contain at least one saxon:catch child, and it may
contain several. Each one specifies which errors it is intended to catch in its errors attribute;
the value * catches all errors. The first saxon:catch to match the error code is the
one that is evaluated. The saxon:catch children must come after all other children, with the
exception of any xsl:fallback children (which can be included to define fallback behaviour by processors
that do not recognize the saxon:try instruction.
The saxon:try element may have either a select attribute, or a sequence of
child instructions (preceding the first xsl:catch); it must not have both.
saxon:try is available in Saxon-EE only
See also saxon:catch.