Introduction¶
The xmlschema library is an implementation of XML Schema for Python (supports Python 2.7 and Python 3.4+).
This library arises from the needs of a solid Python layer for processing XML Schema based files for MaX (Materials design at the Exascale) European project. A significant problem is the encoding and the decoding of the XML data files produced by different simulation software. Another important requirement is the XML data validation, in order to put the produced data under control. The lack of a suitable alternative for Python in the schema-based decoding of XML data has led to build this library. Obviously this library can be useful for other cases related to XML Schema based processing, not only for the original scope.
The full xmlschema documentation is available on “Read the Docs”.
Features¶
This library includes the following features:
Full XSD 1.0 support
Building of XML schema objects from XSD files
Validation of XML instances against XSD schemas
Decoding of XML data into Python data and to JSON
Encoding of Python data and JSON to XML
Data decoding and encoding ruled by converter classes
An XPath based API for finding schema’s elements and attributes
Support of XSD validation modes
Remote attacks protection by default using an XMLParser that forbids entities
Installation¶
You can install the library with pip in a Python 2.7 or Python 3.4+ environment:
pip install xmlschema
The library uses the Python’s ElementTree XML library and requires elementpath additional package. The base schemas of the XSD standards are included in the package for working offline and to speed-up the building of schema instances.