Your package looks promising.
I encountered an issue while generating models from a xsd.
The dataclass models work fine while the pydantic models don't.
It seems to me that there is a problem in how optional fields are generated (only for --output pydantic)
You'll see the difference in the following image (for the same initial DPEv2.2.xsd file), where fields where tagged "optional" in the dataclass version while they were not in the pydantic. Maybe this is due to the fact that these fields are grouped in a <xsd:all> tag ?!
I generated the models from the same xsd like this :
# Uncomment to work on models_pydantic version
# from models_pydantic import Dpe
# from xsdata_pydantic.bindings import XmlParser
# Uncomment to work on models_dataclass version
from models_dataclass import Dpe
from xsdata.formats.dataclass.parsers import XmlParser
parser = XmlParser()
result = parser.parse("2344E0308327N.xml", Dpe)
murs = result.logement.enveloppe.mur_collection.mur
for mur in murs:
print(mur.donnee_entree.surface_paroi_totale)
You'll find the example xsd and xml files here : mwe.zip
Hi @tefra,
Your package looks promising. I encountered an issue while generating models from a xsd. The
dataclass
models work fine while thepydantic
models don't.It seems to me that there is a problem in how optional fields are generated (only for
--output pydantic
) You'll see the difference in the following image (for the same initialDPEv2.2.xsd
file), where fields where tagged "optional" in thedataclass
version while they were not in thepydantic
. Maybe this is due to the fact that these fields are grouped in a<xsd:all>
tag ?!I generated the models from the same xsd like this :
And run the following code on a sample xml file
You'll find the example
xsd
andxml
files here : mwe.zip