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

Method iter_errors

xmlschema/dataobjects.py:284–306  ·  view source on GitHub ↗

Generates a sequence of validation errors if the XML data object is invalid. Accepts the same arguments of :meth:`validate`.

(self, use_defaults: bool = True,
                    namespaces: Optional[NsmapType] = None,
                    max_depth: Optional[int] = None)

Source from the content-addressed store, hash-verified

282 return error is None
283
284 def iter_errors(self, use_defaults: bool = True,
285 namespaces: Optional[NsmapType] = None,
286 max_depth: Optional[int] = None) -> Iterator['XMLSchemaValidationError']:
287 """
288 Generates a sequence of validation errors if the XML data object is invalid.
289 Accepts the same arguments of :meth:`validate`.
290 """
291 if self._encoder is None:
292 raise XMLSchemaValueError("%r has no schema bindings" % self)
293
294 kwargs: dict[str, Any] = {
295 'namespaces': self.get_namespaces(namespaces, root_only=False),
296 'converter': DataElementConverter,
297 'use_defaults': use_defaults,
298 }
299 if isinstance(max_depth, int) and max_depth >= 0:
300 kwargs['max_depth'] = max_depth
301
302 for result in self._encoder.iter_encode(self, **kwargs):
303 if isinstance(result, validators.XMLSchemaValidationError):
304 yield result
305 else:
306 del result
307
308 def encode(self, validation: str = 'strict', **kwargs: Any) -> EncodeType[ElementType]:
309 """

Callers 13

validateMethod · 0.95
is_validMethod · 0.95
test_validationMethod · 0.45
test_missing_childMethod · 0.45
iter_errorsFunction · 0.45

Calls 3

get_namespacesMethod · 0.95
XMLSchemaValueErrorClass · 0.90
iter_encodeMethod · 0.45