You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 versionfrommodels_dataclassimportDpefromxsdata.formats.dataclass.parsersimportXmlParserparser=XmlParser()
result=parser.parse("2344E0308327N.xml", Dpe)
murs=result.logement.enveloppe.mur_collection.murformurinmurs:
print(mur.donnee_entree.surface_paroi_totale)
You'll find the example xsd and xml files here : mwe.zip
The text was updated successfully, but these errors were encountered:
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 initial
DPEv2.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.zipThe text was updated successfully, but these errors were encountered: