pyxsd.schematron.model¶
Native Schematron validation report and message value model.
The native model is the stable surface between the rule driver, the message
expander, and the serializers. Validation returns one immutable
SchematronReport. Original-instance outcomes are produced in
candidate-major order: every active pattern or group attempts a candidate
before the next candidate, and each fired rule emits its checks in authored
order. An ordinary pattern fires its first matching rule at a node; every
matching rule of an independent 2025 group fires. Without a phase from,
outcomes from a container’s subordinate documents follow that original
traversal, grouped by container and then by the documents query’s order; a
bounded phase switches to the document-major order described below. Active
patterns and groups and fired rules are retained even when they produce no
outcome, because a report describes what the schema did, not only what failed.
Every record carries the pattern_ordinal of the container that produced it:
the container’s position in the compiled schema’s native order. That ordinal,
paired with the document URI, is the native identity that pairs an active
container with its own fired rules and outcomes. The authored pattern_id is
optional, so it never identifies a record: two identifier-less containers stay
distinct through their ordinals.
Every firing also carries a report-unique firing_id, and every outcome
carries the identity of the firing that produced it. That is the exact pairing
key for identifier-less group rules that fire at one node, where an ordinal
plus context cannot tell two firings apart. A report also retains the instance
documents it owned, primary first, so a serializer can distinguish a real
instance node from a constructed temporary tree without guessing from a path.
The message classes are data containers. The message stage fills them from a check’s compiled message, its diagnostics, and its properties; serializers read the parts and their flattened text without reparsing anything.
A 2025 phase/@from narrows candidate traversal for the original document
only; documents admitted through pattern/@documents remain unrestricted.
The native active-pattern record for the original document retains the
effective roots, in document order and deduplicated by identity, while an
empty selection keeps an empty tuple and its document identity. A bounded
validation produces outcomes in document-major order: the original document’s
selected candidates first, then each distinct subordinate document in first
seen order, and for every candidate the applicable patterns in native order.
A validation without a phase from keeps the pre-existing candidate-major
original traversal followed by subordinate passes grouped by container.
A 2025 visit-each firing keeps two identities. The fired rule’s context
and every outcome’s context stay the outer matched rule node, while each
outcome carries its own visited item plus zero-based visited_ordinal.
The firing itself retains only the item count and a bounded preview, so a huge
sequence is never duplicated into the report; serializers emit that count and
preview and mark a truncated payload. A visited instance node may act as the
default subject; atomic and synthetic items never acquire an invented node path
or byte span.
Attributes¶
Classes¶
One evaluated component of a native Schematron message. |
|
One check, diagnostic, or property message as native structured parts. |
|
One reusable diagnostic resolved for an outcome. |
|
One reusable property resolved for an outcome. |
|
One pattern or group that was active for one document. |
|
One rule that matched one context node in one pattern. |
|
One failed assertion or successful report. |
|
The immutable result of one native validation. |
Module Contents¶
- pyxsd.schematron.model.OutcomeKind¶
- pyxsd.schematron.model.VISITED_PREVIEW_LIMIT = 10¶
- class pyxsd.schematron.model.MessagePart¶
One evaluated component of a native Schematron message.
textis the component’s flattened string value.nodesretains the XDM nodes avalue-ofornameselected, in selection order.name,attributes, andchildrendescribe one markup element; literal text has no nodes or markup. The rule driver’s message expansion fills this model by evaluating compiled parts at the rule focus; serializers read the parts and never reparse or invent content. A selected node from a constructed temporary tree is not a validated instance node: JSON reportsinstance_node: falsewith a null path, document URI, and span, and no serializer fabricates a location for it. A node from a foreign parsed document keeps that document’s real URI withinstance_node: falseand a null path and span: it owns the URI but has no validated instance path.- nodes: tuple[pyxsd.xdm.nodes.XdmNode, ...] = ()¶
- children: tuple[MessagePart, ...] = ()¶
- class pyxsd.schematron.model.SchematronMessage¶
One check, diagnostic, or property message as native structured parts.
- parts: tuple[MessagePart, ...]¶
- class pyxsd.schematron.model.DiagnosticMessage¶
One reusable diagnostic resolved for an outcome.
idis the authored diagnostic identifier andmessageits evaluated parts.originis the diagnostic’s schema occurrence;languageandroleare the diagnostic’s own metadata, never the referencing check’s.- message: SchematronMessage¶
- origin: pyxsd.locations.IssueLocation | None¶
- class pyxsd.schematron.model.PropertyMessage¶
One reusable property resolved for an outcome.
A property carries a
schemein addition to the diagnostic metadata, and its message may name the context node.- message: SchematronMessage¶
- origin: pyxsd.locations.IssueLocation | None¶
- class pyxsd.schematron.model.ActivePattern¶
One pattern or group that was active for one document.
pattern_idisNonefor an identifier-less container, which can only be active when no phase restricts the active set.originis the container’s schema occurrence, anddocument_uriis the URI of the instance document it applied to, when it has one.kinddistinguishes an ordinary pattern from a 2025 independent rule group; it defaults to"pattern"for a pre-group constructor call shape.pattern_ordinalis the container’s position in the compiled schema’s native order; one container applied to two documents yields two records that share the ordinal and differ indocument_uri.rootsrecords an effective 2025phase/@fromroot set for the original document:Nonewhen no phasefromapplied or when this is an admitted subordinate document, an empty tuple when the original document’s selection was empty (the record stays because the pattern was still active), and otherwise the effective nodes in document order, deduplicated by identity.fromnever restricts a subordinate document, so a subordinate record always carriesNone. Every selected root belongs to the original document and lies within any supplied validation subtree.title,role, anddocuments_sourceare the compiled container metadata the 2025 SVRL active-set attributes report: the authored title (including an empty one), the authored role, and the lexical@documentsquery source.documents_sourceis notdocument_uri; it says what the container queried, while the record’s owndocument_urisays which document this run describes.- origin: pyxsd.locations.IssueLocation | None¶
- kind: pyxsd.schematron.ir.PatternKind = 'pattern'¶
- roots: tuple[pyxsd.xdm.nodes.XdmNode, ...] | None = None¶
- class pyxsd.schematron.model.FiredRule¶
One rule that matched one context node in one pattern.
A fired rule is retained even when every check passed or produced no report.
contextis the matched instance node; node identity, not a path string, distinguishes repeated firings.pattern_ordinalis the producing pattern or group’s position in the compiled schema’s native order, the identity it shares with its active-pattern record and outcomes.visited_countis the number of items the 2025@visit-eachexpression selected:Nonewhen the rule has no@visit-each,0when it selected nothing, and the sequence length otherwise.visited_previewis at mostVISITED_PREVIEW_LIMITleading items, so a firing never retains an unbounded sequence; each outcome still keeps its own visited item. The preview preserves native identity for the serializer, it is not a second copy of the result. The visited items never replacecontext: the outer matched node remains the rule-selection identity, while each outcome also retains its own visited item.firing_idis the runtime-assigned identity of this firing within its report. It is a native pairing key, never an authored identifier and never a fabricated SVRL attribute; identifier-less group rules that fire at one node stay distinct through it.visit_each_sourceis the compiled@visit-eachexpression text,flagits resolved rule flag token list, androleits resolved rule role.- context: pyxsd.xdm.nodes.XdmNode¶
- origin: pyxsd.locations.IssueLocation | None¶
- visited_preview: tuple[pyxsd.xdm.values.XdmItem, ...] = ()¶
- class pyxsd.schematron.model.SchematronOutcome¶
One failed assertion or successful report.
kinddistinguishes anassertwhose effective boolean value was false from areportwhose effective boolean value was true.testis the compiled test’s source text andcontextthe rule’s matched node.subjectsholds the subject nodes in selection order: the rule context when neither the check nor the rule declares a subject, an empty tuple for an explicitly empty selection, and every selected node otherwise.primary_subjectis the first selected subject, or the rule context when the selection is empty; serializers use it for the generic location without dropping the remaining subjects.messageis the check’s evaluated message, anddiagnosticsandpropertiesare its referenced reusable messages in authored reference order.flagsis the check’s flag token list, inherited from the rule when the check declares none.language,role,severity,see,fpi, andiconare retained as resolved strings; no severity is inferred from a flag, and a 2025severitynever changes the outcome kind, validity, or generic issue severity.pattern_ordinalis the producing pattern or group’s position in the compiled schema’s native order, the identity it shares with its active-pattern record and fired rules.visitedis the 2025visit-eachitem whose focus produced this outcome, andvisited_ordinalis its zero-based position in the sequence. Both areNonefor a rule without@visit-each.contextalways stays the outer matched rule node, so the two identities never collapse. A visited node that belongs to an instance tree supplies the default subject; an atomic item, or a synthetic node with no tree root, supplies no subject and therefore no invented path or byte span.primary_subjectstill falls back to the real outercontextin that case.firing_idis the runtime-assigned identity of the firing that produced this outcome, the same value carried by itsFiredRule. It pairs outcomes with their own firing even when several identifier-less group rules fire at one node; it is never an authored identifier or an SVRL attribute.- kind: OutcomeKind¶
- context: pyxsd.xdm.nodes.XdmNode¶
- origin: pyxsd.locations.IssueLocation | None¶
- message: SchematronMessage | None = None¶
- subjects: tuple[pyxsd.xdm.nodes.XdmNode, ...] = ()¶
- diagnostics: tuple[DiagnosticMessage, ...] = ()¶
- properties: tuple[PropertyMessage, ...] = ()¶
- visited: pyxsd.xdm.values.XdmItem | None = None¶
- property primary_subject: pyxsd.xdm.nodes.XdmNode¶
The first subject, or the rule context when none was selected.
- Return type:
- class pyxsd.schematron.model.SchematronReport¶
The immutable result of one native validation.
schemaandinstanceare the inputs the report describes; they are excluded from equality and repr so a report compares by its own findings.phaseis the phase selector the caller supplied, including a dynamic#ANYtoken.resolved_phaseis the native authored phase that selection actually chose, orNonewhen every pattern ran without a selected phase. SVRL and JSON report the resolved identity; they never serialize a pseudo-selector as a phase name. Outcomes retain production order.is_validis true exactly when no assertion failed: successful reports never invalidate an instance.documentsholds every instance document this validation owned, in first-seen order: the supplied primary document followed by each distinct admitted subordinate document. It is the native ownership set serializers use to decide whether a message-part or visited node has a real instance location; a constructed temporary tree or foreign document is not in it. Like the inputs, it is excluded from equality and repr.- schema: pyxsd.schematron.ir.CompiledSchema¶
- instance: pyxsd.xdm.nodes.XdmNode¶
- active_patterns: tuple[ActivePattern, ...]¶
- outcomes: tuple[SchematronOutcome, ...]¶
- documents: tuple[pyxsd.xdm.nodes.XdmDocument, ...] = ()¶
- property failed_assertions: tuple[SchematronOutcome, ...]¶
Outcomes produced by assertions whose test was false.
- Return type:
- property successful_reports: tuple[SchematronOutcome, ...]¶
Outcomes produced by reports whose test was true.
- Return type:
- to_validation_report()¶
Project failed assertions and successful reports to generic issues.
A failed assertion becomes an error with code
schematron-failed-assertand a successful report becomes a warning with codeschematron-successful-report. The outcome kind alone selects the severity;flagvalues never do. Each issue points at the outcome’s primary subject and carries the native identifiers, flags, metadata, message, all subjects, diagnostics, and properties in itsdetails.- Return type:
- to_svrl()¶
Serialize this report as ISO 2025 SVRL.
Serialization reads only the native active-set, fired-rule, and outcome records. No instance text is reparsed, no XSLT is run, and the output contains no generator marker. Firing identity pairs outcomes with their own firing, and a document location is emitted only where the grammar’s anyURI type can represent it.
- Return type:
- to_json()¶
Serialize this report as deterministic, object-explicit JSON.
The payload states the outcome kind, firing identity, identifiers, flags, link metadata, message parts, subject paths and spans, diagnostics, properties, the caller’s phase selector, the resolved phase identity, document identity, and validity with plain JSON values only.
- Return type: