XmlContext#
- class xsdata.formats.dataclass.context.XmlContext(element_name_generator=<function return_input>, attribute_name_generator=<function return_input>, class_type='dataclasses', models_package=None)[source]#
The models context class.
The context is responsible to provide binding metadata for models and their fields.
- Parameters:
- cache#
Internal cache for binding metadata instances
- xsi_cache#
Internal cache for xsi types to class locations
- sys_modules#
The number of loaded sys modules
- get_builder(globalns=None)[source]#
Return a new xml meta builder instance.
- Return type:
XmlMetaBuilder
- fetch(clazz, parent_ns=None, xsi_type=None)[source]#
Build the model metadata for the given class.
- Parameters:
- Return type:
- Returns:
A xml meta instance
- is_binding_model(clazz)[source]#
Return whether the clazz is a binding model.
If the models package is not empty also validate the class is located within that package.
- 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_by_fields(field_names)[source]#
Find a data class that matches best the given list of field names.
- find_subclass(clazz, qname)[source]#
Find a subclass for the given clazz and xsi:type qname.
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, globalns=None)[source]#
Fetch or build the binding metadata for the given class.
- build_recursive(clazz, parent_ns=None)[source]#
Build the binding metadata for the given class and all of its dependencies.
This method is used in benchmarks!
- local_names_match(names, clazz)[source]#
Check if the given field names match the given class type.
Silently ignore, typing errors. These classes are from third party libraries most of them time.