Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DTD code generator #688

Merged
merged 10 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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