Skip to main content

Module xsd

Module xsd 

Source
Expand description

XML Schema 1.0 — schema compiler and instance validator.

Re-exports the public surface of sup_xml_core::xsd. See that module for the conventions.

§Quick start

use sup_xml::xsd::Schema;

let schema = Schema::compile_str(r#"
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
               targetNamespace="urn:demo" xmlns="urn:demo">
      <xs:element name="port" type="xs:int"/>
    </xs:schema>"#)?;

schema.validate_str(r#"<port xmlns="urn:demo">8080</port>"#)?;

Structs§

FsResolver
Look for schema files on the filesystem relative to a base directory.
InMemoryResolver
Map literal schemaLocation strings to schema bytes held in memory. Useful for embedding schemas in a binary, for tests, or for proxying to an in-process schema cache.
NoResolver
A resolver that always declines. Used by Schema::compile_str for single-file schemas — any <xs:import> or <xs:include> becomes a compile error.
QName
A namespace-qualified XML name. XSD operates entirely in terms of these — local names alone are insufficient when a schema imports other namespaces.
Schema
The top-level compiled schema. Cheap to clone (one Arc bump).
SchemaCompileError
Error returned by Schema::compile_str and friends. Schema compilation produces at most one error — the compiler bails on the first problem since later phases assume a well-formed type graph.
SchemaOptions
Knobs for Schema::compile_str_with_options / Schema::compile_with_options.
ValidationError
Returned by Schema::validate_str. May contain one or many issues depending on ValidationOptions::fail_fast.
ValidationIssue
One validation problem discovered while walking an instance document.
ValidationOptions
Tunables for Schema::validate_str_opts.

Enums§

BuiltinType
One of the XSD built-in datatypes. Simple types defined in user schemas reference one of these as their ultimate base.
SchemaVersion
Which XSD version the compiler should target. XSD 1.1 is a strict superset of 1.0 — every 1.0 schema is also a valid 1.1 schema — so the choice only matters when a schema uses a 1.1-specific construct (xs:assert, xs:alternative, xs:override, wildcard notQName / notNamespace, the 1.1-added built-in datatypes, …).
TypeRef
A type reference — either a simple or complex type. Used everywhere an element’s type=... is resolved.
ValidationKind
Categorical tag for a validation issue. Use for programmatic dispatch rather than string-matching the message.

Traits§

SchemaResolver
Resolves a schema-location hint to the XSD bytes for that schema.