#[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.
| Mode | Root’s element_decl | schema_type | [validity], [validation attempted] | Errors of its own |
|---|---|---|---|---|
Declaration | the top-level declaration of its name | the declaration’s type (or xsi:type, a type alternative) | strict assessment | cvc-elt.1 when undeclared and without xsi:type |
Element(D) | D | D’s type (or xsi:type, a type alternative) | strict assessment | cvc-elt.1 when the root’s name is not D’s |
Type(T) | none | T, or an xsi:type that overrides it | strict assessment | cvc-elt.4.* for an xsi:type that does not override T, cvc-type.2 for an abstract governing type |
Lax | as Declaration | as Declaration | strict when declared or xsi:type names a type; otherwise notKnown, and none / partial | none for an undeclared root |
#[non_exhaustive], so further modes can be added.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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.1unresolved,cvc-elt.4.2not derived,cvc-elt.4.3blocked), 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); anxsi:typethat 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:nilis checked as anxs:booleanattribute and the content against the type.- PSVI:
element_declNone,schema_typethe governing type,type_sourceTypeSource::Stipulatedfor the stipulated type andTypeSource::XsiTypefor an overridingxsi: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.