Skip to main content

Convert XML Schema Definitions to Voluptuous schemas.

Project description

xsd-to-vol

ci Code style: black Open Issues Release

Convert XML Schema Definition files to voluptuous schemas.

Binary file usage

Basic usage:

xml-to-vol -i schema.xsd -o schema.py

Basic pipe usage:

cat schema.xsd | xml-to-vol > schema.py

Pipe through black formatter:

cat schema.xsd | xsd-to-vol | black - > schema.py

Advanced piping example with curl:

curl -s https://api-test.geofox.de/gti/public/geofoxThinInterfacePublic.xsd 2>&1 | xsd-to-vol | black - > schema.py

You can also mix input/output files and stdin/stdout.

Library usage

You can also use the xml_to_vol method to convert your schema:

from xsd_to_vol import xsd_to_vol

with open("schema.xsd", 'r') as schema_file:
    xsd = schema_file.read()
    print(xsd_to_vol(xsd))

To Do

While the generation should work for most xsd files, there are some features I'd like to have in future versions:

  • Only include used imports: Currently all possible voluptuous requirements are imported. The required imports can be determined.
  • Tests: Gather different xsd schemas and build pytests to test the generation.
  • Automatic code formatting: Run black over the code (without piping).

Contributions are welcome!

If you want to contribute to this, please read the Contribution guidelines

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xsd-to-vol-0.0.6.tar.gz (14.0 kB view hashes)

Uploaded Source

Built Distribution

xsd_to_vol-0.0.6-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page