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
This fails to work when parsing the XML with e with stack trace:
Traceback (most recent call last):
File "...", line 38, in <module>
pp = E.from_xml(x.encode())
^^^^^^^^^^^^^^^^^^^^^^
File "...", line 346, in from_xml
return cls.from_xml_tree(etree.fromstring(source), context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...y", line 329, in from_xml_tree
obj = typing.cast(ModelT, cls.__xml_serializer__.deserialize(XmlElement.from_native(root), context=context))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...", line 178, in deserialize
result = {
^
File "...", line 181, in <dictcomp>
if (field_value := field_serializer.deserialize(element, context=context)) is not None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...", line 358, in deserialize
return self._model.__xml_serializer__.deserialize(sub_element, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...", line 187, in deserialize
return self._model.model_validate(result, strict=False, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...", line 503, in model_validate
return cls.__pydantic_validator__.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for B
x
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
It is the intended behavior that sub-model inherits its parent namespace implicitly if it is not explicitly defined.
So it your case you should define X namespace like this:
Hi,
I'm trying to parse an XML file from a third party with a structure like:
I have defined these models:
This fails to work when parsing the XML with e with stack trace:
Doing some digging. I think the problematic line is here: https://github.com/dapper91/pydantic-xml/blob/master/pydantic_xml/serializers/factories/model.py#L286
its passing the parents ns "soap" which does not exist in the nsmap and the qualified name becomes
X
instead of{"http://www.example.com/"}X
The text was updated successfully, but these errors were encountered: