oxml
🌐 EN , Change language
llms.txt

Documentation

xmlschema — XSD 1.0 Validator

Rigorous W3C XML Schema validation engine built for enterprise compliance and high assurance pipelines.

Installation

Add xmlschema to your dependencies:

[dependencies]
xmlschema = "0.0.13"

Validation Example

Validate XML documents against standard XSD schemas:

use xmlschema::{parse_schema, validate};

let xsd = std::fs::read_to_string("schema.xsd")?;
let schema = parse_schema(&xsd)?;

let xml = std::fs::read_to_string("document.xml")?;
let doc = oxml::parse(&xml)?;
let report = validate(&doc, &schema);

if report.is_valid() {
    println!("Document is strictly valid!");
} else {
    for violation in &report.violations {
        eprintln!("Validation error: {violation}");
    }
}

Supported Types & Facets

  • Simple types: string, integer, decimal, boolean, dateTime, date, anyURI, hexBinary, base64Binary
  • Complex types: sequences, choices, all groups, attribute declarations
  • Restriction facets: minInclusive, maxInclusive, minExclusive, maxExclusive, length, minLength, maxLength, pattern (regex engine), enumeration
  • Value-space comparisons: enumerations compare in the datatype value space (e.g. true and 1, numeric formatting, case-insensitive hexBinary)
  • Binary length validation: octet-based length validation for xs:hexBinary and xs:base64Binary
  • W3C Conformance: 95.2% pass rate over 35,942 decided tests (34,226 pass, 0 panics) across the 39,420-test W3C XSD test suite.