xsdata.formats.dataclass.context module¶
-
class
xsdata.formats.dataclass.context.
XmlContext
(element_name=<function XmlContext.<lambda>>, attribute_name=<function XmlContext.<lambda>>, cache=<factory>, xsi_cache=<factory>)[source]¶ Bases:
object
Generate and cache the necessary metadata to bind an xml document data to a dataclass model.
- Parameters
-
element_name
()¶
-
attribute_name
()¶
-
cache
: Dict[Type, xsdata.formats.dataclass.models.elements.XmlMeta]¶
-
fetch
(clazz, parent_ns=None, xsi_type=None)[source]¶ Fetch the model metadata of the given dataclass type, namespace and xsi type.
- Parameters
- Return type
-
find_types
(qname)[source]¶ Find all classes that match the given xsi:type qname.
Ignores native schema types, xs:string, xs:float, xs:int, …
Rebuild cache if new modules were imported since last run
-
find_type
(qname)[source]¶ Return the most recently imported class that matches the given xsi:type qname.
-
find_subclass
(clazz, qname)[source]¶ Compare all classes that match the given xsi:type qname and return the first one that is either a subclass or shares the same parent class as the original class.
-
build
(clazz, parent_ns=None)[source]¶ Fetch from cache or build the metadata object for the given class and parent namespace.
-
classmethod
resolve_namespaces
(xml_type, namespace, parent_namespace)[source]¶ Resolve the namespace(s) for the given xml type and the parent namespace.
Only elements and wildcards are allowed to inherit the parent namespace if the given namespace is empty.
In case of wildcard try to decode the ##any, ##other, ##local, ##target.
-
classmethod
real_types
(type_hint)[source]¶ Return a list of real types that can be used to bind or cast data.
-
classmethod
is_derived
(obj, clazz)[source]¶ Return whether the given obj is derived from the given dataclass type.