Skip to main content

Python XML Binding

Project description

image

Naive XML Bindings for python

image image image image image image


xsData is a complete data binding library for python allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.

The code generator supports XML schemas, DTD, WSDL definitions, XML & JSON documents. It produces simple dataclasses with type hints and simple binding metadata.

The included XML and JSON parser/serializer are highly optimized and adaptable, with multiple handlers and configuration properties.

xsData is constantly tested against the W3C XML Schema 1.1 test suite.

Getting started

$ # Install all dependencies
$ pip install xsdata[cli,lxml,soap]
$ # Generate models
$ xsdata generate tests/fixtures/primer/order.xsd --package tests.fixtures.primer
>>> from tests.fixtures.primer import PurchaseOrder
>>> from xsdata.formats.dataclass.parsers import XmlParser
>>>
>>> parser = XmlParser()
>>> order = parser.parse("tests/fixtures/primer/sample.xml", PurchaseOrder)
>>> order.bill_to
Usaddress(name='Robert Smith', street='8 Oak Avenue', city='Old Town', state='PA', zip=Decimal('95819'), country='US')

Check the documentation for more ✨✨✨

Features

Code Generator

  • XML Schemas 1.0 & 1.1
  • WSDL 1.1 definitions with SOAP 1.1 bindings
  • DTD external definitions
  • Directly from XML and JSON Documents
  • Extensive configuration to customize output
  • Pluggable code writer for custom output formats

Default Output

  • Pure python dataclasses with metadata
  • Type hints with support for forward references and unions
  • Enumerations and inner classes
  • Support namespace qualified elements and attributes

Data Binding

  • XML and JSON parser, serializer
  • PyCode serializer
  • Handlers and Writers based on lxml and native xml python
  • Support wildcard elements and attributes
  • Support xinclude statements and unknown properties
  • Customize behaviour through config

Changelog: 24.12 (2024-12-22)

Fixes

  • Set the default value of prohibited fields to None (#1098)

  • Set body and fault as optional in output soap classes (#1099)

  • Resolve a conflict with type location when an element and a complex type have the same name (#1107)

Features

  • Allow Xml Parser subclasses to override how the root class is located (#1090)

  • Include common soap encoding schema (#1100)

Deprecations

  • Remove subscritable types config option
  • Remove Type,Tuple,List,Dict from stop words
  • Deprecate xsdata shorthand, use xsdata generate instead

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

xsdata-24.12.tar.gz (343.6 kB view details)

Uploaded Source

Built Distribution

xsdata-24.12-py3-none-any.whl (232.6 kB view details)

Uploaded Python 3

File details

Details for the file xsdata-24.12.tar.gz.

File metadata

  • Download URL: xsdata-24.12.tar.gz
  • Upload date:
  • Size: 343.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xsdata-24.12.tar.gz
Algorithm Hash digest
SHA256 67c16c032bbde82c064f6c28cdf6b4f8adcbd0498e2668a346ff8e52a3a200b4
MD5 e42b56a983e64854bfaab578e4f5378d
BLAKE2b-256 2982c2b73724bdd31f81e263e1f87e4b9bd70703dd4282ce44ffe1978cda541b

See more details on using hashes here.

File details

Details for the file xsdata-24.12-py3-none-any.whl.

File metadata

  • Download URL: xsdata-24.12-py3-none-any.whl
  • Upload date:
  • Size: 232.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xsdata-24.12-py3-none-any.whl
Algorithm Hash digest
SHA256 2656cfa7240d215a4f2ff30abeebee9afad1e72b805f3ed29ded518a7d3785ee
MD5 d8089f95d80a70c34605730d428cfc32
BLAKE2b-256 0ce570026869f5ab3c6be413ab5a978849cfe2037f2e82bd1da8550c7627caa3

See more details on using hashes here.

Supported by

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