Closed psongers closed 8 months ago
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:
class X(BaseXmlModel, tag="X", ns='', nsmap={"": "http://www.example.com/"}):
result: str = element(tag="Y")
or this:
class B(BaseXmlModel, ns="soap", tag="Body"):
x: X = element(ns='')
bug fixed in version 2.4.0
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