pyxsd.schematron.errors ======================= .. py:module:: pyxsd.schematron.errors .. autoapi-nested-parse:: 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 :class:`pyxsd.exceptions.PyXSDError`, so callers may catch either the specific contract or the common family. Exceptions ---------- .. autoapisummary:: pyxsd.schematron.errors.SchematronError pyxsd.schematron.errors.SchematronCompileError pyxsd.schematron.errors.SchematronEvaluationError pyxsd.schematron.errors.SchematronLimitError Module Contents --------------- .. py:exception:: SchematronError Base class for every fatal Schematron failure. .. py:exception:: 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. .. py:property:: location :type: pyxsd.locations.IssueLocation | None The source occurrence where the failure was detected, when known. .. py:exception:: 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. .. py:attribute:: location :value: None .. py:attribute:: schema_location :value: None .. py:attribute:: pattern_id :value: None .. py:attribute:: rule_id :value: None .. py:attribute:: check_id :value: None .. py:attribute:: code :value: None .. py:attribute:: cause :value: None .. py:attribute:: stage :value: None .. py:attribute:: document_uri :value: None .. py:attribute:: outer_context :value: None .. py:attribute:: visited_ordinal :value: None .. py:attribute:: visited_item :value: None .. py:exception:: 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. .. py:property:: stage :type: str The compiler or validator stage that exhausted the budget. .. py:property:: budget :type: str The limit field name that was exhausted. .. py:property:: configured :type: int The caller's configured value for this budget. .. py:property:: observed :type: int The observed count that exceeded the configured value.