--- id: xmlschema version: "4.3.2" license: MIT license_treatment: permissive maintenance: active --- # xmlschema — An XML Schema validator and decoder License: permissive · Maintenance: active · Downloads: 8.5M/mo ## What it is and what it does xmlschema is a Python implementation of XML Schema (XSD) that validates XML documents and converts between XML, Python data structures, and JSON. It supports both XSD 1.0 and XSD 1.1 standards and includes built-in base schemas for offline operation. The library was originally developed to handle schema-based XML processing for the MaX European research project but is applicable to any XML Schema validation or data binding task. The package provides validation in strict, lax, and skip modes, protects against XML attacks by forbidding entities, and offers XPath-based APIs for navigating schemas. It can decode XML into nested Python dictionaries with type-aware values, encode Python data back to XML, and generate static code using Jinja2 templates. The single runtime dependency (elementpath) keeps installation lightweight. Use it for: - Validate XML configuration files or data exports against a schema before processing. - Decode XML documents into Python dictionaries for programmatic access to typed data. - Encode Python data structures back to XML while enforcing schema constraints. - Build XML data bindings or generate Python classes from XSD schemas. - Protect against XML entity attacks by parsing untrusted XML with entity forbidding enabled. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Validates XML documents against XSD schemas and converts XML to/from Python data structures and JSON. Yes. xmlschema is actively maintained, has no known vulnerabilities, requires only Python 3.10+, and carries a permissive MIT license. It is the standard choice for schema-based XML processing in Python when XSD validation or structured XML-to-Python conversion is needed. ## Install pip install xmlschema uv add xmlschema poetry add xmlschema ## Installing xmlschema Before you install: Low friction: pure Python wheel with a single runtime dependency (elementpath). Active maintenance with a release 45 days ago and ongoing commits. License in practice: MIT license permits unrestricted use, modification, and distribution in commercial and private projects. Quickstart: pip install xmlschema import xmlschema my_schema = xmlschema.XMLSchema('path/to/schema.xsd') my_schema.is_valid('path/to/document.xml') data = my_schema.to_dict('path/to/document.xml') Requires Python 3.10 or later. Verify before relying: - Whether XSD 1.1 support is production-ready or still experimental relative to XSD 1.0. - Performance characteristics when validating large XML files or deeply nested schemas. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 8.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags XML schema validation, XSD validator, XML to Python conversion, XML data decoding, schema-based XML processing, xml-schema, data-validation, serialization [View on SkillFed](https://skillfed.io/packages/xmlschema) · [View on PyPI](https://pypi.org/project/xmlschema/)