I just want to know if there is a program that can convert an XSD file to a Python class as JAXB does for Java?
generateDS : I think this is the good tool I need
Edit : Actually, generateDS does very well the job !! It generates the Python class with all methods (setters and getters, export to XML, import from XML). It works very well !
xsdata generates dataclasses from an XSD file. According to the documentation it was inspired by JAXB.
For anyone coming across this question now (in 2021) I suggest checking out xmlschema
I tried the above suggestions (despite the EOL warnings), but wasn't enjoying the experience. Then I discovered xmlschema, and parsed my data in just 3 lines, including the import.
>> import xmlschema
>> data_schema = xmlschema.XMLSchema('my_schema.xsd')
>> data=data_schema.to_dict('my_data.xml')
The imported data is a nested dictionary, with keys and values that match the schema. Beautiful!
Look at http://pypi.python.org/pypi/rsl.xsd/0.2.3
Also, you might want http://pyxsd.org/ it works very nicely.
© 2022 - 2024 — McMap. All rights reserved.