-
-
Notifications
You must be signed in to change notification settings - Fork 79
-
Hi,
Sounds like I'm missing something.
I used xsdata cli to generate some python code from an existing xsd.
Everything seems OK and required data seem to be generated accordingly to xsd definition.
When parsing a conform file (xmllint gives no validation error), no error. The object is created with as imagined
When parsing an invalid file (xmllint raises a validation error), there is no error either. The object is created with missing required informations.
I guess I'm missing something but what ?
Regards,
Laurent
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Basically in dataclasses field with default values have to be declared before any other field, but xsdata relies on the field ordering for the serialization. For that reason the generator marks all fields as Optional[...] despite what you see in the field metadata={"required": true}
That part of the metadata currently is completely imformative for the developer.
In Python 3.10 dataclasses introduced a new directive kw_only that resolves the above limitation and xsdata handling. Read more
Beta Was this translation helpful? Give feedback.
All reactions
-
I have the same question: how to enforce XML elements' and attributes' content validation (for example by regex or by string/integer type).
Unfortunately the both links today lead to incorrect locations.
Could you give us updated links? Could you recommend some approach to XML content validation?
Beta Was this translation helpful? Give feedback.