pyxsd.xslt.errors

Errors raised by the advisory inspector and the normative XSLT front end.

The advisory inspection error is an input/resource failure only. Normative errors carry the expanded XSLT or XPath error name, the phase that discovered the problem, the stylesheet module and package identity when known, the source location, any frame-derived dynamic stack, and the preserved underlying cause. Static errors use the exact code the specification assigns; a generic exception must never be substituted for one of them.

Errors keep their own identity at XSLT boundaries. A parser, resource, XPath, or Python exception is wrapped only where the runtime has deliberately converted it into an XSLT dynamic error; its original object is retained as cause and __cause__. Callback failures that were not deliberately converted are not catchable by a coded xsl:catch and are not eligible for implementation recovery.

Attributes

Exceptions

XsltInspectionError

Advisory stylesheet inspection could not read or bind its inputs.

XsltError

Base class for normative XSLT compilation and execution errors.

XsltStaticError

A static error, reported before any transformation output starts.

XsltDynamicError

A dynamic error raised while executing a transformation.

XsltCircularityError

An engine-detected circularity, reported as XTDE0640.

XsltSerializationError

A serialization error, distinct from the transformation's dynamic phase.

Functions

normalized_error_code(code)

Return the local part of one error code without assuming a namespace.

is_static_error_code(code)

Whether code identifies a static XPath or XSLT error.

expanded_error_code(code)

Return one error code as an expanded QName when its namespace is known.

error_code_from_exception(…)

Extract a specification error code from an exception without rewriting it.

is_budget_alarm(error)

Whether error is an execution-budget alarm rather than an engine failure.

Module Contents

pyxsd.xslt.errors.ERROR_NAMESPACE = 'http://www.w3.org/2005/xqt-errors'
pyxsd.xslt.errors.IMPLEMENTATION_BUDGET_CODE = 'PYXSD-XSLT-001'
pyxsd.xslt.errors.UNSUPPORTED_FEATURE_CODE = 'PYXSD-XSLT-002'
pyxsd.xslt.errors.normalized_error_code(code)

Return the local part of one error code without assuming a namespace.

Parameters:

code (str | None)

Return type:

str | None

pyxsd.xslt.errors.is_static_error_code(code)

Whether code identifies a static XPath or XSLT error.

XPST/XQST are static XPath/XQuery errors and XTSE is the XSLT static-error family. XSLT 3.0 section 8.3 says static errors are never caught, so these codes stay outside xsl:try even if a processor reports them while executing an expression.

Parameters:

code (str | None)

Return type:

bool

pyxsd.xslt.errors.expanded_error_code(code)

Return one error code as an expanded QName when its namespace is known.

A bare local code belongs to the standard error namespace. A prefixed code with an unknown prefix cannot be expanded without a static context, so it is returned unchanged rather than guessed.

Parameters:

code (str | None)

Return type:

str | None

pyxsd.xslt.errors.error_code_from_exception(error: BaseException, default: None = None) → str | None
pyxsd.xslt.errors.error_code_from_exception(error: BaseException, default: str) → str

Extract a specification error code from an exception without rewriting it.

Standard error-namespace codes are returned in their familiar local form. A custom QName is preserved as an expanded name so an extension error in a non-standard namespace can still match a coded xsl:catch. default supplies the fallback used by callers whose boundary maps an unidentifiable failure to a specific error code.

exception pyxsd.xslt.errors.XsltInspectionError

Advisory stylesheet inspection could not read or bind its inputs.

This is an input/resource failure, not an XSLT static error. Schema legality findings and instance binding findings are reported on report instead.

exception pyxsd.xslt.errors.XsltError(message, *, code=None, phase=None, uri=None, module=None, package=None, location=None, stack=(), cause=None, description=None, has_description=True, value=(), line_number=None, column_number=None)

Base class for normative XSLT compilation and execution errors.

code is an XSLT (XTSE/XTTE/XTDE) or XPath (XPST/ XPTY) error code, stored as supplied. phase names the processing phase, uri/module the relevant stylesheet or resource, package the containing package, and location one source occurrence. stack is derived from explicit execution frames, never from the Python call stack. cause preserves a parser, resource, expression, or callback exception instead of replacing its identity with this error.

description, value, line_number, and column_number carry the standard err:* catch metadata. has_description distinguishes an explicitly absent description (fn:error with one argument) from an empty one. Line and column numbers remain None when the source occurrence does not carry them.

Parameters:
code = None
phase = None
uri = None
module = None
package = None
location = None
stack: tuple[pyxsd.xslt.runtime.frames.FrameDiagnostic, ...] = ()
cause = None
description
has_description = True
value: tuple[pyxsd.xdm.XdmItem, ...] = ()
messages: tuple[pyxsd.xslt.results.Message, ...] = ()
warnings: tuple[str, ...] = ()
line_number = None
column_number = None
property expanded_code: str | None

The error code as an expanded QName, when its namespace is known.

Return type:

str | None

property catchable: bool

Whether a coded xsl:catch may consume this error.

Only dynamically signaled XSLT/XPath errors are catchable. Static and serialization errors are outside xsl:try, and a foreign callback failure is not converted merely because it crossed an XSLT boundary.

Return type:

bool

matches_catch(errors=None, *, namespaces=None)

Whether one xsl:catch/@errors list selects this error.

Parameters:
Return type:

bool

attach_diagnostics(stack, *, module=None, package=None)

Attach frame-derived context only where it is not already known.

Parameters:
Return type:

None

attach_messages(messages, warnings)

Retain messages and warnings emitted before this failure.

A failed transformation never returns a result, so its diagnostics would otherwise be lost at the host boundary. Messages already attached by an inner invocation stay first; the outer invocation’s own messages follow.

Parameters:
Return type:

None

exception pyxsd.xslt.errors.XsltStaticError(message, *, code=None, phase='static', uri=None, module=None, package=None, location=None, stack=(), cause=None, description=None, has_description=True, value=(), line_number=None, column_number=None)

A static error, reported before any transformation output starts.

A static-expression failure keeps its original XPath code; a stylesheet resource or structural failure uses the exact XTSE code for that rule.

Parameters:
exception pyxsd.xslt.errors.XsltDynamicError(message, *, code=None, phase='dynamic', uri=None, module=None, package=None, location=None, stack=(), cause=None, allow_catch=True, description=None, has_description=True, value=(), line_number=None, column_number=None)

A dynamic error raised while executing a transformation.

code is normally an XSLT XTDE/XTTE code or an XPath error code. The execution runtime’s own resource limits use the stable implementation code PYXSD-XSLT-001; callers can test it exactly without depending on message text. allow_catch is false for foreign callback failures that crossed an XSLT boundary without being deliberately converted.

Parameters:
allow_catch = True
property catchable: bool

Whether a coded xsl:catch may consume this error.

Only dynamically signaled XSLT/XPath errors are catchable. Static and serialization errors are outside xsl:try, and a foreign callback failure is not converted merely because it crossed an XSLT boundary.

Return type:

bool

exception pyxsd.xslt.errors.XsltCircularityError(message, **kwargs)

An engine-detected circularity, reported as XTDE0640.

XSLT 3.0 section 5.5.4 makes a dynamic error during pattern evaluation a non-match, but requires a circularity to be reported even there. This marker distinguishes the engine’s own circularity from an unrelated dynamic error that happens to carry the same code (for example a forged xsl:message code), which the masking rule still covers.

Parameters:
  • message (str)

  • kwargs (Any)

exception pyxsd.xslt.errors.XsltSerializationError(message, *, code=None, phase='serialization', uri=None, module=None, package=None, location=None, stack=(), cause=None, secondary=False, description=None, has_description=True, value=(), line_number=None, column_number=None)

A serialization error, distinct from the transformation’s dynamic phase.

A serialization error while writing a secondary result is treated as a dynamic error of the xsl:result-document instruction and may be caught; a principal-result serialization error happens after the transformation and cannot be caught. secondary records which boundary raised it.

Parameters:
secondary = False
property catchable: bool

Whether a coded xsl:catch may consume this error.

Only dynamically signaled XSLT/XPath errors are catchable. Static and serialization errors are outside xsl:try, and a foreign callback failure is not converted merely because it crossed an XSLT boundary.

Return type:

bool

pyxsd.xslt.errors.is_budget_alarm(error)

Whether error is an execution-budget alarm rather than an engine failure.

Two independent budgets can expire while the engine works, and neither one describes a failure of the stylesheet or of the expression being evaluated:

  • the caller’s wall-clock alarm, which the conformance harness raises as a TimeoutError from SIGALRM; and

  • the engine’s own ExecutionLimits budget, which arrives as a dynamic error carrying IMPLEMENTATION_BUDGET_CODE.

A handler that converts a caught exception into a non-match or a different error must let both through unchanged. Converting the alarm cancels the bound the caller placed on the work, so the runaway expression keeps running instead of stopping at its budget.

TimeoutError is class-only: socket.timeout, asyncio.TimeoutError and concurrent.futures.TimeoutError are that class on Python 3.11+, so a foreign timeout arriving at a guarded engine site is treated as an alarm. Extension and Python-rule callbacks are converted at their own boundary before this predicate ever sees the error.

Parameters:

error (BaseException)

Return type:

bool