XmlContext¶
-
class
xsdata.formats.dataclass.context.
XmlContext
(element_name=<function XmlContext.<lambda>>, attribute_name=<function XmlContext.<lambda>>)[source]¶ The service provider for binding operations metadata.
- Parameters
- Variables
cache – Cache models metadata
xsi_cache – Index models by xsi:type
sys_modules – Number of imported modules
-
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_type_by_fields
(field_names)[source]¶ Find a dataclass from all the imported modules that matches the given list of field names.
-
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 binding metadata 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
default_value
(var)[source]¶ Return the default value/factory for the given dataclass field.
-
classmethod
real_types
(type_hint)[source]¶ Return a list of real types that can be used to bind or cast data.