Skip to main content

Module resolver

Module resolver 

Source
Expand description

Schema resolution for include, import, and redefine directives

This module handles resolving and loading external schema documents referenced by xs:include, xs:import, and xs:redefine directives.

§Resolution Process

  1. Include - Same target namespace, required schemaLocation

    • Loads the referenced schema
    • Merges components into the same namespace
    • Supports chameleon includes (no targetNamespace)
  2. Import - Different namespace, optional schemaLocation

    • Loads schema for the specified namespace
    • Components remain in their declared namespace
    • Without schemaLocation, relies on catalog or pre-loaded schemas
  3. Redefine - Same namespace, extends/restricts existing types

    • Deprecated in XSD 1.1 (use override instead)
    • Allows redefining types/groups from included schema

§Circular Dependencies

The resolver tracks loaded schema locations to:

  • Detect circular includes (allowed, just skip)
  • Prevent infinite loops
  • Enable caching of resolved schemas

§URI Resolution

The resolver supports:

  • Absolute file paths
  • Relative paths (resolved against base URI)
  • HTTP/HTTPS URLs (via async trait)
  • Catalog-based resolution

§Customizable Loading

The SchemaLoader trait allows custom loading strategies:

Structs§

CatalogEntry
A single catalog entry
EmbeddedLoader
Embedded resource loader for built-in schemas.
FileSystemLoader
File system schema loader (default).
LoaderChain
Composite loader that chains multiple loaders.
ResolutionResult
Result of resolving all directives in a schema
ResolverConfig
Configuration for schema resolution
SchemaCatalog
Catalog for mapping namespaces to schema locations
SchemaResolver
Schema resolver for loading external schema documents.

Enums§

LoadOutcome
Result of a single load_schema call, distinguishing three outcomes.

Traits§

SchemaLoader
Trait for loading schema content from various sources.

Functions§

decode_xml_bytes
Decode raw XML bytes into a UTF-8 String, sniffing common Unicode encodings per XML 1.0 §F.1. See decode_xml_to_utf8_bytes.
decode_xml_to_utf8_bytes
Decode raw XML bytes into UTF-8 bytes, sniffing common Unicode encodings per XML 1.0 §F.1.
fixup_composition_edges
Fixup pass: fill in target_doc on cycle edges whose target has since been loaded. Call after all directive resolution rounds complete.
resolve_all_directives
Resolve all directives in a schema document