pyxsd.schematron.svrl¶
Native SVRL, JSON, and generic validation projections.
Every serializer reads the immutable native report directly. Active patterns,
fired rules, and outcomes are never inferred from a path string, reparsed from
instance text, or reordered beyond the SVRL grouping that the standard
requires: each native active-set record is an empty root child followed by its
fired rules and their outcomes as root-level siblings, in production order.
A record belongs to its active set through the pattern ordinal it carries and
its document URI, never through the optional authored id: several
identifier-less containers on one document therefore keep their own rules and
outcomes, and no identifier is invented for them. Outcomes pair with a fired
rule through the runtime’s immutable firing_id, not through list position,
so identifier-less group rules that fire at one node stay distinct.
The serializer emits the 2025 SVRL shape. Ordinary patterns become
svrl:active-pattern and independent groups become svrl:active-group;
each carries the grammar-defined @id, @name (the authored title),
@role, and @documents (the lexical @documents query source, never
the loaded instance URI). A fired rule carries its real outer context
document location in @document, its compiled @visit-each expression
text, and its resolved rule flag/role. XSD 1.0 rejects the common
file:///path anyURI form because its authority is empty, so a local file
URI is represented by the same already-percent-encoded path with only that
empty authority removed (file:/path); the native model and JSON keep the
exact URI, and a malformed file URI is omitted rather than renamed. A failed
assertion or successful report carries its dynamic severity, its token-list
flags, and its rich text. The root carries the schema’s
schematronEdition and the resolved phase identity; the caller’s
#ANY/#ALL/#DEFAULT selector is never serialized as a phase name.
SVRL uses a fixed svrl prefix unless a schema namespace already claims it.
Element and attribute names in location paths use Clark notation, while foreign
rich-text markup receives deterministic nsN prefixes that avoid every
declared prefix. JSON and generic issues encode explicit fields and spans; no
serializer writes an object repr, a generator comment, or a library
marker. A constructed temporary-tree node never contributes a synthetic path,
document URI, or byte span: JSON states that explicitly and SVRL simply omits
what the grammar cannot carry. A foreign parsed document’s node keeps its own
real URI but gains no path or span it does not own as a validated instance.
Standard SVRL cannot represent every native detail. A diagnostic’s role
is emitted on svrl:diagnostic-reference for a 2025-edition schema, the
only one whose grammar permits it; for any other schema it is omitted, so a
report built from 2016 constructs stays valid 2016 SVRL. Diagnostic language
moves to the nested svrl:text; property role/scheme remain on
svrl:property-reference. A firing identity, role on an outcome attached
to no active slot, and other native-only values remain in the native model
and JSON.
Malformed reports and rich content that cannot be represented losslessly raise
SchematronSerializationError before invalid SVRL is returned. The
2025 grammar admits zero active sets only in its error-only form, which normal
validation never produces; a normal report with no active pattern or group
therefore raises instead of emitting an unrepresentable document.
schematron_error_to_svrl() is the explicit path for a caught native
error: it emits a grammar-valid root-level svrl:error from the error’s
typed document/location/code fields. Normal validation still raises, and no
caught error is ever converted into a successful report or an instance
verdict.
Attributes¶
Exceptions¶
One native report or rich-text value has no lossless standard SVRL form. |
Functions¶
|
Project report to one |
|
Serialize report as deterministic JSON with explicit field names. |
|
Serialize report as an ISO 2025 SVRL document. |
|
Serialize one caught native error as a grammar-valid |
Module Contents¶
- pyxsd.schematron.svrl.SVRL_NS = 'http://purl.oclc.org/dsdl/svrl'¶
- exception pyxsd.schematron.svrl.SchematronSerializationError¶
One native report or rich-text value has no lossless standard SVRL form.
The serializer raises this before returning output for a report with no active pattern or group, records for an undeclared active set, outcomes without their firing rule, ambiguous firings that carry no native identity, a phase value that is not an
xsd:NMTOKEN, a malformed flag token list, a subject outside every instance document, or message parts that the SVRL grammar cannot represent. It also rejects characters forbidden by XML 1.0.
- pyxsd.schematron.svrl.validation_report(report)¶
Project report to one
ValidationReport.- Parameters:
- Return type:
- pyxsd.schematron.svrl.serialize_json(report)¶
Serialize report as deterministic JSON with explicit field names.
- Parameters:
- Return type:
- pyxsd.schematron.svrl.serialize_svrl(report)¶
Serialize report as an ISO 2025 SVRL document.
A report from a schema that neither declares the 2025 edition nor uses a 2025 construct is also valid against the 2016 SVRL grammar.
- Parameters:
- Return type:
- pyxsd.schematron.svrl.schematron_error_to_svrl(error)¶
Serialize one caught native error as a grammar-valid
svrl:error.This is the only API that turns an operational failure into SVRL; normal validation never catches an error into a report. The result has the error-only root form the 2025 grammar allows: one root-level
svrl:schematron-outputwith onesvrl:errorchild. Its required@documentand@locationcome from the error’s typed fields, never from its rendered message:a compile error uses its schema occurrence’s source as the document and that occurrence’s element path as the location;
an evaluation error uses its owning instance document location and instance location;
a limit error, or any error without an occurrence, uses empty values, which the grammar permits only as the genuinely unknown address.
@codeis the preserved XSLT/XPath code when one exists. The rendered message is escaped character content of thesvrl:errorelement, not asvrl:textchild (the 2025 grammar does not admit one there), and it is never reparsed.- Parameters:
- Return type: