Skip to content

Commit

Permalink
Merge pull request #688 from tefra/dtd
Browse files Browse the repository at this point in the history
Implement DTD code generator
  • Loading branch information
tefra authored Jul 9, 2022
2 parents fa9f014 + 9578ad3 commit 7eede8e
Show file tree
Hide file tree
Showing 27 changed files with 1,248 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .bandit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[bandit]
exclude: tests/,docs/
skips: B701
skips: B701,B410
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ exclude: tests/fixtures

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
rev: v2.34.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.1.0
rev: v3.3.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
Expand All @@ -26,7 +26,7 @@ repos:
args: ["--suppress-none-returning"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -37,7 +37,7 @@ repos:
- id: docformatter
args: ["--in-place", "--pre-summary-newline"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.950
rev: v0.961
hooks:
- id: mypy
additional_dependencies: [tokenize-rt, types-requests, types-Jinja2, types-click, types-docutils]
Expand All @@ -47,6 +47,6 @@ repos:
- id: setup-cfg-fmt
args: ["--max-py-version=3.11"]
- repo: https://github.com/PyCQA/doc8
rev: 0.11.1
rev: 0.11.2
hooks:
- id: doc8
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Naive XML Bindings for python
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.

It ships with a code generator for XML schemas, WSDL definitions, XML & JSON documents.
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
Expand Down Expand Up @@ -76,6 +76,7 @@ Features

- 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
Expand Down
2 changes: 1 addition & 1 deletion docs/codegen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Generate Code


.. code-block:: console
:caption: Scan directory for xsd, wsdl, xml files
:caption: Scan directory for xsd, dtd, wsdl, xml or json files
$ xsdata amadeus/schemas --package amadeus.models
Expand Down
1 change: 1 addition & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Code Generation
examples/docstrings
examples/xml-modeling
examples/json-modeling
examples/dtd-modeling
examples/compound-fields
examples/dataclasses-features

Expand Down
20 changes: 20 additions & 0 deletions docs/examples/dtd-modeling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
============
DTD Modeling
============

The code generator supports processing external document type definitions (DTD).

.. code-block:: console
$ xsdata --package tests.fixtures.dtd.models tests/fixtures/dtd/complete_example.dtd
.. tab:: DTD Definition

.. literalinclude:: /../tests/fixtures/dtd/complete_example.dtd
:language: dtd

.. tab:: Output

.. literalinclude:: /../tests/fixtures/dtd/models/complete_example.py
:language: python
9 changes: 9 additions & 0 deletions docs/faq/error-parsing-dtd.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DTDParseError: error parsing DTD
================================

xsdata works only with **external** document type definitions
and relies on `lxml <https://lxml.de/>`_ exclusively to parse
the dtd tree.

Try to remove the `DOCTYPE` wrapper if you are sure the rest of
the definition is correct.
Loading

0 comments on commit 7eede8e

Please sign in to comment.