Skip to main content

SchemaSet

Struct SchemaSet 

Source
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: NameTable

String interning table for names and namespace URIs

§source_maps: SourceMapStorage

Centralized 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: XsdVersion

XSD version mode (1.0 or 1.1)

§regex_compatibility: RegexCompat

Regex compatibility mode for pattern facets. Default Strict.

§arenas: SchemaArenas

Arena 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

Source

pub fn new() -> Self

Create a new empty schema set

Source

pub fn xsd10() -> Self

Create a new schema set configured for XSD 1.0.

Source

pub fn xsd11() -> Self

Create a new schema set configured for XSD 1.1.

Source

pub fn with_version(version: XsdVersion) -> Self

Create a new schema set with specified version

Source

pub fn is_xsd10(&self) -> bool

Returns true if this schema set is configured for XSD 1.0.

Source

pub fn is_xsd11(&self) -> bool

Returns true if this schema set is configured for XSD 1.1.

Source

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.

Source

pub fn regex_compatibility(&self) -> RegexCompat

Get the regex compatibility mode for this schema set.

Source

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.

Source

pub fn has_parsing_errors(&self) -> bool

Returns true if any parsing errors were collected during error-recovery parsing.

Source

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.

Source

pub fn is_loaded(&self, location: &str) -> bool

Check if a schema location has already been loaded

Source

pub fn mark_loaded(&mut self, location: String, doc_id: DocumentId)

Mark a schema location as loaded

Source

pub fn get_or_create_namespace( &mut self, ns: Option<NameId>, ) -> &mut NamespaceTable

Get or create namespace table for a namespace

Source

pub fn lookup_type(&self, ns: Option<NameId>, name: NameId) -> Option<TypeKey>

Look up a type by namespace and name

Source

pub fn lookup_element( &self, ns: Option<NameId>, name: NameId, ) -> Option<ElementKey>

Look up an element by namespace and name

Source

pub fn lookup_attribute( &self, ns: Option<NameId>, name: NameId, ) -> Option<AttributeKey>

Look up an attribute by namespace and name

Source

pub fn lookup_model_group( &self, ns: Option<NameId>, name: NameId, ) -> Option<ModelGroupKey>

Look up a model group by namespace and name

Source

pub fn lookup_attribute_group( &self, ns: Option<NameId>, name: NameId, ) -> Option<AttributeGroupKey>

Look up an attribute group by namespace and name

Source

pub fn lookup_notation( &self, ns: Option<NameId>, name: NameId, ) -> Option<NotationKey>

Look up a notation by namespace and name

Source

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.

Source

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.

Source

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.

Source

pub fn any_type_key(&self) -> ComplexTypeKey

Get the built-in xs:anyType key.

Source

pub fn is_any_type(&self, type_key: TypeKey) -> bool

Check if the given type key refers to xs:anyType.

Source

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.

Source

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.

Source

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
  • true if derived == base
  • true if derived has base somewhere in its derivation chain
  • false otherwise
Source

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 type
  • base - The potential base type
  • exclude_methods - Derivation methods to exclude from the check. Use DerivationSet::empty() to allow any method (like C#’s Empty).
§Returns
  • true if derived == base
  • true if derived derives from base via a non-excluded derivation method
  • false otherwise
Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for SchemaSet

Source§

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

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

impl Default for SchemaSet

Source§

fn default() -> Self

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

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<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> MaybeSendSync for T

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.