Skip to main content

SchemaResolver

Struct SchemaResolver 

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

Configuration for resolution

Implementations§

Source§

impl SchemaResolver

Source

pub fn new() -> Self

Create a new resolver with default configuration and loader chain.

Uses LoaderChain::with_defaults() which includes:

Source

pub fn with_config(config: ResolverConfig) -> Self

Create a resolver with the specified configuration.

Uses the default loader chain.

Source

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));
Source

pub fn with_config_and_loader( config: ResolverConfig, loader: Box<dyn SchemaLoader>, ) -> Self

Create a resolver with custom configuration and loader.

Source

pub fn catalog_mut(&mut self) -> &mut SchemaCatalog

Get a mutable reference to the catalog

Source

pub fn resolve_location( &self, schema_location: &str, base_uri: &str, ) -> SchemaResult<String>

Resolve a schema location to an absolute path or URL

Source

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.

Source

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

Source

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

Source

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.

Source

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

Source

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

Trait Implementations§

Source§

impl Default for SchemaResolver

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.