MCPcopy Create free account
hub / github.com/sissaschool/xmlschema / get_namespaces

Method get_namespaces

xmlschema/dataobjects.py:230–253  ·  view source on GitHub ↗

Returns an overall namespace map for DetaElement, resolving prefix redefinitions. :param namespaces: builds the namespace map starting over the dictionary provided. :param root_only: if `True` processes only the namespaces declared in the data \ element, otherwise p

(self, namespaces: Optional[NsmapType] = None,
                       root_only: bool = True)

Source from the content-addressed store, hash-verified

228 yield child
229
230 def get_namespaces(self, namespaces: Optional[NsmapType] = None,
231 root_only: bool = True) -> dict[str, str]:
232 """
233 Returns an overall namespace map for DetaElement, resolving prefix redefinitions.
234
235 :param namespaces: builds the namespace map starting over the dictionary provided.
236 :param root_only: if `True` processes only the namespaces declared in the data \
237 element, otherwise precesses also other namespaces declared in its descendants.
238 """
239 if namespaces is None:
240 namespaces = {}
241 else:
242 namespaces = {k: v for k, v in namespaces.items()}
243
244 if root_only:
245 update_namespaces(namespaces, self.nsmap.items(), root_declarations=True)
246 else:
247 nsmap = None
248 for elem in self.iter():
249 if nsmap is not elem.nsmap:
250 nsmap = elem.nsmap
251 update_namespaces(namespaces, nsmap.items(), elem is self)
252
253 return namespaces
254
255 def validate(self, use_defaults: bool = True,
256 namespaces: Optional[NsmapType] = None,

Callers 4

iter_errorsMethod · 0.95
encodeMethod · 0.95
tostringMethod · 0.95
get_namespacesMethod · 0.45

Calls 2

iterMethod · 0.95
update_namespacesFunction · 0.90

Tested by

no test coverage detected