pyxsd.schematron.errors

Schematron exception contracts.

Compilation findings and instance validity stay separate: a malformed, unsupported, or unreadable schema raises a compile error, and an exhausted budget raises a limit error, while only a failed assertion makes an instance invalid. Every exception derives from pyxsd.exceptions.PyXSDError, so callers may catch either the specific contract or the common family.

Exceptions

SchematronError

Base class for every fatal Schematron failure.

SchematronCompileError

A source could not become a Schematron schema.

SchematronEvaluationError

A validation-time expression, function, key, or document operation failed.

SchematronLimitError

A configured Schematron budget was exhausted.

Module Contents

exception pyxsd.schematron.errors.SchematronError

Base class for every fatal Schematron failure.

exception pyxsd.schematron.errors.SchematronCompileError(message, *, location=None)

A source could not become a Schematron schema.

location names the exact source occurrence when the failure has one; a well-formedness failure reported by the XML parser has no element occurrence and therefore no location. The rendered message includes the source name, and a known element occurrence adds its line and column.

Parameters:
property location: pyxsd.locations.IssueLocation | None

The source occurrence where the failure was detected, when known.

Return type:

pyxsd.locations.IssueLocation | None

exception pyxsd.schematron.errors.SchematronEvaluationError(message, *, location=None, schema_location=None, pattern_id=None, rule_id=None, check_id=None, code=None, cause=None, stage=None, document_uri=None, outer_context=None, visited_ordinal=None, visited_item=None)

A validation-time expression, function, key, or document operation failed.

This is an operational failure, never a failed assertion and never a successful report. location names the instance occurrence being evaluated, schema_location the responsible rule, check, or variable declaration, and pattern_id/rule_id/check_id identify the producing definitions when the failure has them. document_uri is the URI of the instance document that owns location, or None when the instance was parsed without one; it is never substituted from the primary document when a visited subordinate supplied the location. stage names the work that failed ("parameters", "let", "visit-each", "phase", "when", "from", "context", "check", "subject", "message", "diagnostic", "property", "flag", "role", "severity", or "documents"), code preserves the original XSLT/XPath error code, and cause retains the original exception. A resource policy’s refusal of a subordinate doc()/document() read is such a failure at any of those stages: cause is that ResourcePolicyError and code is None because no XSLT or XPath error occurred.

outer_context is the structured occurrence of the outer matched rule context, independent of where location points. visited_ordinal and visited_item retain a 2025 @visit-each failure’s item position and bounded display text; they are None when no visited item was in force. visited_item is a display value, not a parsed message field: rewriting the rendered message can never change the structured identity. The explicit svrl:error serializer reads document_uri, location, and code directly. outer_context and the visited fields are typed native identity used to choose the authoritative location; SVRL has no separate slots for them, so its one @location/rich-text pair represents that limit rather than duplicating or reparsing the identities.

Parameters:
location = None
schema_location = None
pattern_id = None
rule_id = None
check_id = None
code = None
cause = None
stage = None
document_uri = None
outer_context = None
visited_ordinal = None
visited_item = None
exception pyxsd.schematron.errors.SchematronLimitError(stage, budget, configured, observed)

A configured Schematron budget was exhausted.

Budget exhaustion is not semantic invalidity: the schema or instance that exceeds a caller’s budget has no verdict. A budget is an inclusive bound, so observing exactly the configured value succeeds and the next unit of work raises. stage names the compiler or validator stage, budget the limit field, configured the caller’s value, and observed the count that crossed it.

Parameters:
property stage: str

The compiler or validator stage that exhausted the budget.

Return type:

str

property budget: str

The limit field name that was exhausted.

Return type:

str

property configured: int

The caller’s configured value for this budget.

Return type:

int

property observed: int

The observed count that exceeded the configured value.

Return type:

int