Skip to main content

ValidationRoot

Enum ValidationRoot 

Source
#[non_exhaustive]
pub enum ValidationRoot { Declaration, Element(ElementKey), Type(TypeKey), Lax, }
Expand description

How a run assesses its validation root — the element its first event opens (Structures §5.2 “Assessing Schema-Validity”). Set with ValidationRuntime::set_validation_root before the root’s element event; the default is Declaration, the behaviour of every run that does not set one.

Every driver that takes the caller’s runtime honours it — drive_quick_xml and its variants, drive_navigator, drive_buffer_document, and the typed build build_typed_document_with (whose TypedBuilderHandler takes each element’s binding from the SchemaInfo the mode produces). build_typed_document, which makes its own runtime, always uses the default.

The mode applies to each validation root of the run: every element started while no element is open. Only the root is affected; its attributes and children are assessed as Structures §3.3.4.6 prescribes for the root’s governing declaration or type. The checks that need the whole run — Validation Root Valid (ID/IDREF) (§3.3.4.5) and identity constraints — apply in every mode.

ModeRoot’s element_declschema_type[validity], [validation attempted]Errors of its own
Declarationthe top-level declaration of its namethe declaration’s type (or xsi:type, a type alternative)strict assessmentcvc-elt.1 when undeclared and without xsi:type
Element(D)DD’s type (or xsi:type, a type alternative)strict assessmentcvc-elt.1 when the root’s name is not D’s
Type(T)noneT, or an xsi:type that overrides itstrict assessmentcvc-elt.4.* for an xsi:type that does not override T, cvc-type.2 for an abstract governing type
Laxas Declarationas Declarationstrict when declared or xsi:type names a type; otherwise notKnown, and none / partialnone for an undeclared root

#[non_exhaustive], so further modes can be added.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Declaration

Strict wildcard validation (§5.2): “The processor starts from Schema-Validity Assessment (Element) (§3.3.4.6) with no stipulated declaration or definition. If the ·validation root· and the schema determine an element declaration (by the name of the element) … or a type definition (via xsi:type), then ·strict· validation is performed”; otherwise the root is laxly assessed and its absence from the schema is reported as cvc-elt.1 — the case §5.2 describes as “the invoking process expects the ·validation root· to be declared and valid and will otherwise report an error to its environment”. The behaviour of a run that sets no mode.

§

Element(ElementKey)

Element-driven validation (§5.2): “the item is validated as described in Schema-Validity Assessment (Element) (§3.3.4.6) (with the stipulated element declaration as the ·governing· declaration)” — §3.3.4.6, governing element declaration, clause “1 A declaration stipulated by the processor”. The declaration governs whatever the root’s name; Element Locally Valid (Element) (§3.3.4.3) “1 D is not ·absent· and E and D have the same expanded name” makes a root of another name invalid (cvc-elt.1; XSD 1.0 §5.2: the application “checks that its {name} and {target namespace} match”). Everything else — xsi:type, xsi:nil, {abstract}, type alternatives, identity constraints — is as for a declared element.

§

Type(TypeKey)

Type-driven validation (§5.2): “If the ·validation root· is an element, then it is validated as described in Schema-Validity Assessment (Element) (§3.3.4.6) (with the stipulated type definition as the ·governing type definition·)”. The root has no governing element declaration, even when a top-level declaration of its name exists (§3.3.4.6, governing element declaration clause 4.2: none is resolved by name when “the processor has stipulated a type definition for E”).

  • xsi:type: the governing type is “1 An ·instance-specified type definition· which ·overrides· a type definition stipulated by the processor”, else “2 A type definition stipulated by the processor”. It overrides when ·validly substitutable· for the stipulated type “subject to the blocking keywords in the union of K and T.{prohibited substitutions}” with K empty (§3.3.4.2; XSD 1.0 §3.3.4 clause 1.2.1.2.4: “validly derived from that type definition given its {prohibited substitutions}”). One that does not is reported as for a declared element (cvc-elt.4.1 unresolved, cvc-elt.4.2 not derived, cvc-elt.4.3 blocked), the root is invalid, and the stipulated type stays governing.
  • Abstract: an abstract governing complex type is cvc-type.2 (Element Locally Valid (Type) §3.3.4.4 clause 2); an xsi:type that overrides it with a concrete type is valid.
  • xsi:nil: ·nilled· is defined “with respect to some element declaration D” with “D.{nillable} = true” (§3.3.1), so the root is never nilled: xsi:nil is checked as an xs:boolean attribute and the content against the type.
  • PSVI: element_decl None, schema_type the governing type, type_source TypeSource::Stipulated for the stipulated type and TypeSource::XsiType for an overriding xsi:type; strictly assessed (§3.3.4.6 clause 1.2), so [validity] is valid or invalid.
  • A simple type is allowed (§3.3.4.4 clause 3.1: no attributes but xsi:*, no element children, the text String Valid).
§

Lax

Lax wildcard validation (§5.2): as Declaration when the root’s name resolves to a top-level declaration or its xsi:type to a type — “then ·strict validation· is performed. If they do not identify any declaration or definition, then ·lax assessment· is performed” (“analogous to the validation of an element information item which matches a lax wildcard”): “E is locally ·validated· with respect to ·xs:anyType·” and the schema-validity of “E’s [attributes] and [children] is assessed” (§3.3.4.6) — a declared child or a globally declared attribute strictly, and its errors reported.

A laxly assessed root has no type and no declaration, its [validity] is notKnown whatever its attributes and children (§3.3.5.1 clause 2: “2 otherwise notKnown”), and its [validation attempted] none, or partial when an attribute or child was assessed. No cvc-elt.1 is reported. As for an element a lax wildcard matched, an attribute of its own that its global declaration finds invalid, and an xsi:type that names no type (cvc-elt.4.1; no ·instance-specified type definition·, §3.3.4.1), are reported, and the root stays notKnown. The root is ·nilled· only with a declaration (§3.3.1): with an xsi:type alone, xsi:nil is an attribute and the content is checked against the type.

A host that wants an xsi:type attribute alone not to cause strict validation passes no xsi:type to the element event.

Trait Implementations§

Source§

impl Clone for ValidationRoot

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ValidationRoot

Source§

impl Debug for ValidationRoot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValidationRoot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ValidationRoot

Source§

impl PartialEq for ValidationRoot

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ValidationRoot

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.