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.
- InMemory
Resolver - Map literal
schemaLocationstrings 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_strfor 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
Arcbump). - Schema
Compile Error - Error returned by
Schema::compile_strand friends. Schema compilation produces at most one error — the compiler bails on the first problem since later phases assume a well-formed type graph. - Schema
Options - Knobs for
Schema::compile_str_with_options/Schema::compile_with_options. - Validation
Error - Returned by
Schema::validate_str. May contain one or many issues depending onValidationOptions::fail_fast. - Validation
Issue - One validation problem discovered while walking an instance document.
- Validation
Options - Tunables for
Schema::validate_str_opts.
Enums§
- Builtin
Type - One of the XSD built-in datatypes. Simple types defined in user schemas reference one of these as their ultimate base.
- Schema
Version - 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, wildcardnotQName/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. - Validation
Kind - Categorical tag for a validation issue. Use for programmatic dispatch rather than string-matching the message.
Traits§
- Schema
Resolver - Resolves a schema-location hint to the XSD bytes for that schema.