pub struct DocumentValidator<'a> { /* private fields */ }Expand description
Validates instance documents against a compiled schema.
Holds a ValueValidator, so simple types are prepared once and reused across
documents.
Implementations§
Source§impl<'a> DocumentValidator<'a>
impl<'a> DocumentValidator<'a>
pub fn new(schemas: &'a Schemas) -> Self
Sourcepub fn validate(&self, xml: &str) -> ValidationReport
pub fn validate(&self, xml: &str) -> ValidationReport
Validates a document, discarding the PSVI.
Sourcepub fn validate_with(
&self,
xml: &str,
sink: impl FnMut(PsviEvent),
) -> ValidationReport
pub fn validate_with( &self, xml: &str, sink: impl FnMut(PsviEvent), ) -> ValidationReport
Validates a document, handing every PSVI event to sink.
A callback rather than an iterator: the events are produced inside the streaming loop, and an iterator would have to buffer them.
Sourcepub fn validate_named(
&self,
xml: &str,
uri: &str,
sink: impl FnMut(PsviEvent),
) -> ValidationReport
pub fn validate_named( &self, xml: &str, uri: &str, sink: impl FnMut(PsviEvent), ) -> ValidationReport
Names the document for diagnostics, e.g. a file path.
Sourcepub fn validate_until(
&self,
xml: &str,
uri: &str,
sink: impl FnMut(PsviEvent) -> ControlFlow<()>,
) -> ValidationReport
pub fn validate_until( &self, xml: &str, uri: &str, sink: impl FnMut(PsviEvent) -> ControlFlow<()>, ) -> ValidationReport
Self::validate_named, stopping as soon as sink returns
ControlFlow::Break.
For a reader that has what it came for, or has gone away, and should not pay for the rest of a large document. No event follows the one the break answered. The report covers what was read and nothing more, so a stopped read says nothing about whether the rest is valid.