Expand description
Validating documents, and the report that comes back.
The algorithm is in spec/validation/. The one rule to carry in your
head: within a single pattern, each node is processed by at most one
rule — the first whose context matches it. Rules in one pattern compete
like the arms of a match expression; rules in different patterns do not.
§Examples
use schematron::{Document, Schema};
use schematron::validate::{PhaseSelection, ValidateOptions};
let schema = Schema::from_str(r#"
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<phase id="strict"><active pattern="totals"/></phase>
<pattern id="totals">
<rule context="invoice">
<assert test="total">An invoice must have a total.</assert>
</rule>
</pattern>
</schema>
"#)?;
let document = Document::from_str("<invoice/>")?;
let options = ValidateOptions::new().with_phase(PhaseSelection::Named("strict".into()));
let report = schema.validate_with(&document, &options)?;
assert_eq!(report.count_failures(), 1);
assert_eq!(report.failures().next().unwrap().location, "/invoice[1]");Structs§
- Active
Pattern - A pattern that ran against a document.
- Assertion
Result - One finding: a failed assertion or a successful report.
- Diagnostic
Result - One instantiated diagnostic attached to a finding.
- Fired
Rule - A rule that matched a node, and what it found there.
- Property
Result - One instantiated property attached to a finding.
- Report
- The result of validating one document against one schema.
- Validate
Options - How to run a validation.
Enums§
- Phase
Selection - Which phase of the schema to run.
- Result
Kind - Which kind of finding an assertion produced.