pub struct SchemaSet {
pub name_table: NameTable,
pub source_maps: SourceMapStorage,
pub documents: Vec<SchemaDocument>,
pub namespaces: HashMap<Option<NameId>, NamespaceTable>,
pub xsd_version: XsdVersion,
pub regex_compatibility: RegexCompat,
pub arenas: SchemaArenas,
pub loaded_locations: HashMap<String, DocumentId>,
pub chameleon_cache: HashMap<(String, NameId), DocumentId>,
pub composition_edges: Vec<CompositionEdge>,
pub effective_components: HashMap<ComponentIdentity, EffectiveComponent>,
pub parsing_errors: Vec<SchemaError>,
/* private fields */
}Expand description
Complete schema set (possibly from multiple documents)
This is the main entry point for working with XSD schemas. It owns all schema components and provides namespace-based lookup.
Fields§
§name_table: NameTableString interning table for names and namespace URIs
source_maps: SourceMapStorageCentralized source map storage for all documents
documents: Vec<SchemaDocument>All parsed schema documents
namespaces: HashMap<Option<NameId>, NamespaceTable>Per-namespace component tables (keyed by NameId; None = no namespace)
xsd_version: XsdVersionXSD version mode (1.0 or 1.1)
regex_compatibility: RegexCompatRegex compatibility mode for pattern facets. Default Strict.
arenas: SchemaArenasArena storage for all components
loaded_locations: HashMap<String, DocumentId>Loaded schema locations (for cycle detection)
chameleon_cache: HashMap<(String, NameId), DocumentId>Secondary cache for chameleon schema variants loaded under different
target namespaces. Keyed by (resolved_uri, adopted_namespace).
Allows the same no-namespace schema to be loaded separately for
each including namespace per §4.2.3.
composition_edges: Vec<CompositionEdge>Composition graph edges recorded during directive resolution
effective_components: HashMap<ComponentIdentity, EffectiveComponent>Effective component map with provenance (populated by composition phase).
Keyed by ComponentIdentity so redefine/override replaces the entry
instead of appending, producing the final visible component set.
parsing_errors: Vec<SchemaError>Parsing errors collected during error-recovery mode. These are structural errors that make the schema invalid but were deferred so parsing could continue for better diagnostics.
Implementations§
Source§impl SchemaSet
impl SchemaSet
Sourcepub fn with_version(version: XsdVersion) -> Self
pub fn with_version(version: XsdVersion) -> Self
Create a new schema set with specified version
Sourcepub fn set_regex_compatibility(&mut self, compat: RegexCompat)
pub fn set_regex_compatibility(&mut self, compat: RegexCompat)
Set the regex compatibility mode for this schema set.
Affects how pattern facets in subsequently compiled schemas are
validated. Has no effect on already-compiled patterns. Default is
RegexCompat::Strict.
Sourcepub fn regex_compatibility(&self) -> RegexCompat
pub fn regex_compatibility(&self) -> RegexCompat
Get the regex compatibility mode for this schema set.
Sourcepub fn locate(&self, source: Option<&SourceRef>) -> Option<SourceLocation>
pub fn locate(&self, source: Option<&SourceRef>) -> Option<SourceLocation>
Resolve an optional SourceRef to its line/column location.
Returns None if the source is absent or cannot be located.
Sourcepub fn has_parsing_errors(&self) -> bool
pub fn has_parsing_errors(&self) -> bool
Returns true if any parsing errors were collected during error-recovery parsing.
Sourcepub fn loaded_schema_locations(&self) -> impl Iterator<Item = &str>
pub fn loaded_schema_locations(&self) -> impl Iterator<Item = &str>
Iterate the normalized locations of all loaded schema documents.
Useful for seeding a new [SchemaSetBuilder] with the same schemas
when enriching with xsi:schemaLocation hints.
Sourcepub fn is_loaded(&self, location: &str) -> bool
pub fn is_loaded(&self, location: &str) -> bool
Check if a schema location has already been loaded
Sourcepub fn mark_loaded(&mut self, location: String, doc_id: DocumentId)
pub fn mark_loaded(&mut self, location: String, doc_id: DocumentId)
Mark a schema location as loaded
Sourcepub fn get_or_create_namespace(
&mut self,
ns: Option<NameId>,
) -> &mut NamespaceTable
pub fn get_or_create_namespace( &mut self, ns: Option<NameId>, ) -> &mut NamespaceTable
Get or create namespace table for a namespace
Sourcepub fn lookup_type(&self, ns: Option<NameId>, name: NameId) -> Option<TypeKey>
pub fn lookup_type(&self, ns: Option<NameId>, name: NameId) -> Option<TypeKey>
Look up a type by namespace and name
Sourcepub fn lookup_element(
&self,
ns: Option<NameId>,
name: NameId,
) -> Option<ElementKey>
pub fn lookup_element( &self, ns: Option<NameId>, name: NameId, ) -> Option<ElementKey>
Look up an element by namespace and name
Sourcepub fn lookup_attribute(
&self,
ns: Option<NameId>,
name: NameId,
) -> Option<AttributeKey>
pub fn lookup_attribute( &self, ns: Option<NameId>, name: NameId, ) -> Option<AttributeKey>
Look up an attribute by namespace and name
Sourcepub fn lookup_model_group(
&self,
ns: Option<NameId>,
name: NameId,
) -> Option<ModelGroupKey>
pub fn lookup_model_group( &self, ns: Option<NameId>, name: NameId, ) -> Option<ModelGroupKey>
Look up a model group by namespace and name
Sourcepub fn lookup_attribute_group(
&self,
ns: Option<NameId>,
name: NameId,
) -> Option<AttributeGroupKey>
pub fn lookup_attribute_group( &self, ns: Option<NameId>, name: NameId, ) -> Option<AttributeGroupKey>
Look up an attribute group by namespace and name
Sourcepub fn lookup_notation(
&self,
ns: Option<NameId>,
name: NameId,
) -> Option<NotationKey>
pub fn lookup_notation( &self, ns: Option<NameId>, name: NameId, ) -> Option<NotationKey>
Look up a notation by namespace and name
Sourcepub fn builtin_types(&self) -> &BuiltinTypes
pub fn builtin_types(&self) -> &BuiltinTypes
Get the built-in types registry.
This provides access to well-known type IDs for all 47+ built-in XSD types.
Sourcepub fn get_built_in_simple_type_by_qname(
&self,
namespace: Option<NameId>,
local_name: NameId,
) -> Option<SimpleTypeKey>
pub fn get_built_in_simple_type_by_qname( &self, namespace: Option<NameId>, local_name: NameId, ) -> Option<SimpleTypeKey>
Get a built-in simple type by QName (namespace + local name).
This only looks up built-in types in the XS namespace.
For user-defined types, use lookup_type instead.
§Arguments
namespace- The namespace URI (should be XS namespace for built-in types)local_name- The local name of the type
§Returns
The SimpleTypeKey for the built-in type, or None if not found.
Sourcepub fn get_built_in_type_by_qname(
&self,
namespace: Option<NameId>,
local_name: NameId,
) -> Option<TypeKey>
pub fn get_built_in_type_by_qname( &self, namespace: Option<NameId>, local_name: NameId, ) -> Option<TypeKey>
Get a built-in type by QName (namespace + local name).
This includes the built-in complex type xs:anyType and all built-in simple types.
Sourcepub fn any_type_key(&self) -> ComplexTypeKey
pub fn any_type_key(&self) -> ComplexTypeKey
Get the built-in xs:anyType key.
Sourcepub fn is_any_type(&self, type_key: TypeKey) -> bool
pub fn is_any_type(&self, type_key: TypeKey) -> bool
Check if the given type key refers to xs:anyType.
Sourcepub fn get_built_in_simple_type_by_code(
&self,
code: XmlTypeCode,
) -> Option<SimpleTypeKey>
pub fn get_built_in_simple_type_by_code( &self, code: XmlTypeCode, ) -> Option<SimpleTypeKey>
Get a built-in simple type by its XmlTypeCode.
§Returns
The SimpleTypeKey for the built-in type, or None if not a simple type code.
Sourcepub fn get_type_code(&self, type_id: SimpleTypeKey) -> Option<XmlTypeCode>
pub fn get_type_code(&self, type_id: SimpleTypeKey) -> Option<XmlTypeCode>
Get the XmlTypeCode for a simple type.
Returns None if the type is not a built-in type.
Sourcepub fn derives_from(&self, derived: SimpleTypeKey, base: SimpleTypeKey) -> bool
pub fn derives_from(&self, derived: SimpleTypeKey, base: SimpleTypeKey) -> bool
Check if derived derives from base (transitively).
For built-in types, this uses the standard XSD derivation hierarchy. For user-defined types, this walks the base type chain using resolved references.
§Returns
trueifderived == basetrueifderivedhasbasesomewhere in its derivation chainfalseotherwise
Sourcepub fn is_type_derived_from(
&self,
derived: TypeKey,
base: TypeKey,
exclude_methods: DerivationSet,
) -> bool
pub fn is_type_derived_from( &self, derived: TypeKey, base: TypeKey, exclude_methods: DerivationSet, ) -> bool
Check if derived is derived from base, optionally filtering by derivation method.
This mirrors C#’s XmlSchemaType.IsDerivedFrom(derivedType, baseType, method).
§Arguments
derived- The potentially derived typebase- The potential base typeexclude_methods- Derivation methods to exclude from the check. UseDerivationSet::empty()to allow any method (like C#’s Empty).
§Returns
trueifderived == basetrueifderivedderives frombasevia a non-excluded derivation methodfalseotherwise
Sourcepub fn format_provenance_note(
&self,
kind: ComponentKind,
namespace: Option<NameId>,
name: NameId,
) -> String
pub fn format_provenance_note( &self, kind: ComponentKind, namespace: Option<NameId>, name: NameId, ) -> String
Format a provenance note for a component (returns empty string if none/declared).
Used to enrich error messages with information about where a component originated (e.g., redefined from another schema document).
Sourcepub fn effective_local_element_namespace(
&self,
elem_target_namespace: Option<NameId>,
elem_form: Option<&str>,
source: Option<&SourceRef>,
fallback_namespace: Option<NameId>,
) -> Option<NameId>
pub fn effective_local_element_namespace( &self, elem_target_namespace: Option<NameId>, elem_form: Option<&str>, source: Option<&SourceRef>, fallback_namespace: Option<NameId>, ) -> Option<NameId>
Compute the effective namespace for a local element declaration per XSD spec.
Rules: explicit targetNamespace > form attribute > elementFormDefault > Unqualified. Qualified → document target namespace; Unqualified → None.
Sourcepub fn effective_local_attribute_namespace(
&self,
attr_target_namespace: Option<NameId>,
attr_form: Option<&str>,
source: Option<&SourceRef>,
fallback_namespace: Option<NameId>,
) -> Option<NameId>
pub fn effective_local_attribute_namespace( &self, attr_target_namespace: Option<NameId>, attr_form: Option<&str>, source: Option<&SourceRef>, fallback_namespace: Option<NameId>, ) -> Option<NameId>
Compute the effective namespace for a local attribute declaration per XSD spec.
Rules: explicit targetNamespace > form attribute > attributeFormDefault > Unqualified. Qualified → document target namespace; Unqualified → None.