Naive XML Bindings for python¶
xsData is a complete XML data binding library for python allowing developers to access and use XML documents as simple objects rather than using DOM.
xsData comes with a code generator that can convert XML Schema 1.0 and 1.1 definitions to simple dataclasses with type hints and as minimum footprint as possible. The generated packages have no dependency on the library itself. So simple that you can write the models on your own if you happen to use an XML document with no schema available.
The XML Parser is highly optimized and uses lxml iterparse to bind the document data to the target models. The parser accepts a configuration instance with various options like fail on unknown properties and is also thread safe which means you can take advantage of the internal model inspection caching context for even faster parsing.
The parser and serializer are constantly tested against the W3C XML Schema 1.1 test suite and passes more than 99% of the valid instance cases.
Check the documentation demos or our W3C XML Schema 1.1 test runner and the samples repo for more ✨✨✨
Features¶
Generate data models from XML Schema 1.0 and 1.1 definitions.
Generate data models for WSDL 1.1 and SOAP 1.1 bindings.
Supports qualified elements/attributes.
Supports enumerations and inner classes.
Flattening strategies to keep the code as simple as possible.
Preserve embedded documentation and references
Pluggable code writer that supports different formats
Output: Python Data Classes
Output: PlantUML class diagram
Changelog: 20.8 (2020-08-01)¶
Added codegen support for WSDL 1.1 and SOAP 1.1 bindings.
Added experimental web services client.
Added cli flag
--ns-struct
to group classes by target namespaces. #206Added parser config to support xinclude statements. #207
Added new xml union node to improve bindings for fields with union type. #207
Fixed class resolve issue with mixed namespaces. #204
Fixed attribute comparison issue. #209
Fixed data type mapping for various schema elements. #221
Fixed mixed content handling. #213
Code cleanup & 100% coverage.
Why naive?
The W3C XML Schema offers so much flexibility and abstraction layers and grammatical rules to support practically any xml document definition.
Integration teams and clients don’t care about any of that, take out abstraction and flexibility and you are left with lean named data structures with typed attributes and a namespace for humans to read!