pub struct SchemaResolver {
pub config: ResolverConfig,
/* private fields */
}Expand description
Schema resolver for loading external schema documents.
Uses a SchemaLoader chain to support multiple loading strategies
(file system, embedded assets, HTTP, etc.).
Fields§
§config: ResolverConfigConfiguration for resolution
Implementations§
Source§impl SchemaResolver
impl SchemaResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new resolver with default configuration and loader chain.
Uses LoaderChain::with_defaults() which includes:
EmbeddedLoaderforembedded://URIsFileSystemLoaderfor file paths
Sourcepub fn with_config(config: ResolverConfig) -> Self
pub fn with_config(config: ResolverConfig) -> Self
Create a resolver with the specified configuration.
Uses the default loader chain.
Sourcepub fn with_loader(loader: Box<dyn SchemaLoader>) -> Self
pub fn with_loader(loader: Box<dyn SchemaLoader>) -> Self
Create a resolver with a custom loader.
§Example
use xsd_schema::{SchemaResolver, LoaderChain};
let loader = LoaderChain::with_defaults();
let resolver = SchemaResolver::with_loader(Box::new(loader));Sourcepub fn with_config_and_loader(
config: ResolverConfig,
loader: Box<dyn SchemaLoader>,
) -> Self
pub fn with_config_and_loader( config: ResolverConfig, loader: Box<dyn SchemaLoader>, ) -> Self
Create a resolver with custom configuration and loader.
Sourcepub fn catalog_mut(&mut self) -> &mut SchemaCatalog
pub fn catalog_mut(&mut self) -> &mut SchemaCatalog
Get a mutable reference to the catalog
Sourcepub fn resolve_location(
&self,
schema_location: &str,
base_uri: &str,
) -> SchemaResult<String>
pub fn resolve_location( &self, schema_location: &str, base_uri: &str, ) -> SchemaResult<String>
Resolve a schema location to an absolute path or URL
Sourcepub fn load_schema(
&mut self,
location: &str,
base_uri: &str,
schema_set: &mut SchemaSet,
chameleon_namespace: Option<NameId>,
) -> SchemaResult<LoadOutcome>
pub fn load_schema( &mut self, location: &str, base_uri: &str, schema_set: &mut SchemaSet, chameleon_namespace: Option<NameId>, ) -> SchemaResult<LoadOutcome>
Load and parse a schema from a location.
Returns a LoadOutcome distinguishing freshly loaded, already loaded,
and cycle-in-progress cases.
If chameleon_namespace is Some and the loaded schema has no
targetNamespace, the chameleon namespace is adopted per §4.2.3.
Sourcepub fn load_content(&self, location: &str) -> SchemaResult<String>
pub fn load_content(&self, location: &str) -> SchemaResult<String>
Load content from a location using the configured loader chain.
Supports embedded://, file paths, and potentially HTTP (if configured).
Sourcepub fn process_include(
&mut self,
schema_location: &str,
base_uri: &str,
target_namespace: Option<NameId>,
schema_set: &mut SchemaSet,
) -> SchemaResult<LoadOutcome>
pub fn process_include( &mut self, schema_location: &str, base_uri: &str, target_namespace: Option<NameId>, schema_set: &mut SchemaSet, ) -> SchemaResult<LoadOutcome>
Process an include directive.
Passes target_namespace as the chameleon namespace: if the included
schema has no targetNamespace, it adopts the includer’s (§4.2.3).
Sourcepub fn process_import(
&mut self,
namespace: Option<&str>,
schema_location: Option<&str>,
base_uri: &str,
schema_set: &mut SchemaSet,
) -> SchemaResult<Option<LoadOutcome>>
pub fn process_import( &mut self, namespace: Option<&str>, schema_location: Option<&str>, base_uri: &str, schema_set: &mut SchemaSet, ) -> SchemaResult<Option<LoadOutcome>>
Process an import directive.
Returns Ok(None) only when there is no schemaLocation and no
catalog match (namespace-only import). All other paths return
Ok(Some(LoadOutcome)).
Per src-import (§4.2.6.1) the loaded schema’s targetNamespace is
validated against the directive’s namespace attribute:
1.1 (namespace absent) — the imported schema must have an absent
targetNamespace.
1.2 (namespace present) — the imported schema’s targetNamespace
must equal the directive’s namespace value.
Sourcepub fn process_redefine(
&mut self,
schema_location: &str,
base_uri: &str,
target_namespace: Option<NameId>,
schema_set: &mut SchemaSet,
) -> SchemaResult<LoadOutcome>
pub fn process_redefine( &mut self, schema_location: &str, base_uri: &str, target_namespace: Option<NameId>, schema_set: &mut SchemaSet, ) -> SchemaResult<LoadOutcome>
Process a redefine directive.
Passes target_namespace as the chameleon namespace: if the redefined
schema has no targetNamespace, it adopts the redefiner’s (§4.2.4).
Sourcepub fn process_override(
&mut self,
schema_location: &str,
base_uri: &str,
target_namespace: Option<NameId>,
schema_set: &mut SchemaSet,
) -> SchemaResult<LoadOutcome>
pub fn process_override( &mut self, schema_location: &str, base_uri: &str, target_namespace: Option<NameId>, schema_set: &mut SchemaSet, ) -> SchemaResult<LoadOutcome>
Process an override directive (XSD 1.1).
Passes target_namespace as the chameleon namespace: if the overridden
schema has no targetNamespace, it adopts the overrider’s (§4.2.5).