tuffnatty / xsd_to_django_model Goto Github PK
View Code? Open in Web Editor NEWGenerate Django models from an XSD schema description (and a bunch of hints)
License: GNU General Public License v3.0
Generate Django models from an XSD schema description (and a bunch of hints)
License: GNU General Public License v3.0
Looks like there hasn't been a release in a very long time, though you're up to 1.0.1
Can you do a release?
Invoking xsd_to_django_model
with Python 3.10.11:
Traceback (most recent call last):
File "/Users/user/code/repo/venv/bin/xsd_to_django_model.py", line 42, in <module>
import ndifflib
ModuleNotFoundError: No module named 'ndifflib'
Looks like ndifflib
is not in install_requires
of setup.py
$> python xsd_to_django_model.py schema.xsd types.xsd
ERROR:__main__:EXCEPTION: types.xsd not found in schema
schema.xsd:
<xs:import namespace="types" schemaLocation="types.xsd"/>
Добрый день!
С помощью pip install xsd-to-django-model установил модуль
Вызываю его в терминале - получаю ошибку:
C:\Users\rusagm\Documents\PythonLibs\xsd_to_django_model-0.8.9\xsd_to_django_model-0.8.9\xsd_to_django_model>xsd_to_django_model.py C:\Users\rusagm\Documents\DOMRF\XMLSchemaPersonAdress.xsd Person
Traceback (most recent call last):
File "C:\Users\rusagm\Documents\PythonLibs\xsd_to_django_model-0.8.9\xsd_to_django_model-0.8.9\xsd_to_django_model\xsd_to_django_model.py", line 1812, in
builder.make_models([a.decode('UTF-8') for a in args['<xsd_type>']])
File "C:\Users\rusagm\Documents\PythonLibs\xsd_to_django_model-0.8.9\xsd_to_django_model-0.8.9\xsd_to_django_model\xsd_to_django_model.py", line 1812, in
builder.make_models([a.decode('UTF-8') for a in args['<xsd_type>']])
AttributeError: 'str' object has no attribute 'decode'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\rusagm\Documents\PythonLibs\xsd_to_django_model-0.8.9\xsd_to_django_model-0.8.9\xsd_to_django_model\xsd_to_django_model.py", line 1818, in
logger.error('EXCEPTION: %s', unicode(e))
NameError: name 'unicode' is not defined
I am trying to convert https://ftp.expasy.org/databases/cellosaurus/cellosaurus.xsd to a Django model.
I am not sure what to enter for xsd_type
. The below is not working out for me:
xsd_to_django_model.py cellosaurus.xsd /Cellosaurus
Any pointers on how to pick xsd_type
?
Trying to run xsd_to_django_model
on Cellosaurus version 7.00 with Python 3.11.7 and xsd_to_django_model==1.2.1
:
> xsd_to_django_model.py cellosaurus.xsd /Cellosaurus
WARNING:__main__:Automatic model name: typename1. Consider adding it to TYPE_MODEL_MAP
Making model for type typename1
WARNING:__main__:Automatic model name: typename1.header. Consider adding it to TYPE_MODEL_MAP
Making model for type typename1.header
WARNING:__main__:Automatic model name: typename1.header.release. Consider adding it to TYPE_MODEL_MAP
Making model for type typename1.header.release
Done making model typename1.header.release (typename1.header.release)
WARNING:__main__:Automatic model name: typename1.header.terminology-list. Consider adding it to TYPE_MODEL_MAP
Making model for type typename1.header.terminology-list
WARNING:__main__:Automatic model name: typename1.header.terminology-list.terminology. Consider adding it to TYPE_MODEL_MAP
Making model for type typename1.header.terminology-list.terminology
Done making model typename1.header.terminology-list.terminology (typename1.header.terminology-list.terminology)
ERROR:__main__:EXCEPTION: caught maxOccurs=unbounded in typename1.header.terminology-list.terminology (@type=None). Consider adding it to many_to_many_fields, one_to_many_fields, array_fields, or json_fields
Traceback (most recent call last):
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1508, in make_a_field
rel = model.get('foreign_key_overrides', {})[name]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'header'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1508, in make_a_field
rel = model.get('foreign_key_overrides', {})[name]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'terminology-list'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 2244, in main
builder.make_models([(a.decode('UTF-8') if hasattr(a, 'decode') else a)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1860, in make_models
self.make_model('typename1', self.schema.elements[typename[1:]].type)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1799, in make_model
self.write_seq_or_choice(seq_or_choice, typename, attrs=attrs)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1179, in write_seq_or_choice
self.make_fields(typename, seq_or_choice,
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1635, in make_fields
**self.make_a_field(typename, name, dotted_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1510, in make_a_field
final_type, field = self.get_field(final_type,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1004, in get_field
self.make_model(el_path, element.type)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1799, in make_model
self.write_seq_or_choice(seq_or_choice, typename, attrs=attrs)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1179, in write_seq_or_choice
self.make_fields(typename, seq_or_choice,
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1635, in make_fields
**self.make_a_field(typename, name, dotted_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1510, in make_a_field
final_type, field = self.get_field(final_type,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1004, in get_field
self.make_model(el_path, element.type)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1799, in make_model
self.write_seq_or_choice(seq_or_choice, typename, attrs=attrs)
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1179, in write_seq_or_choice
self.make_fields(typename, seq_or_choice,
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1635, in make_fields
**self.make_a_field(typename, name, dotted_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/code/xsd_to_django_model/venv/bin/xsd_to_django_model.py", line 1568, in make_a_field
(max_occurs == 1) or (field.get('wrap') == "ArrayField"), (
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: caught maxOccurs=unbounded in typename1.header.terminology-list.terminology (@type=None). Consider adding it to many_to_many_fields, one_to_many_fields, array_fields, or json_fields
It looks like it encountered terminology-list
's definition's maxOccurs=unbounded
.
What should one do for maxOccurs=unbounded
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.