Validate the model against the schema, throws an etree.DocumentInvalid if not
(
xml_str: t.Optional[str] = None, xml_doc: t.Optional[ElementT] = None, quiet: bool = False
)
| 32 | |
| 33 | |
| 34 | def validate_view_doc( |
| 35 | xml_str: t.Optional[str] = None, xml_doc: t.Optional[ElementT] = None, quiet: bool = False |
| 36 | ) -> bool: |
| 37 | """Validate the model against the schema, throws an etree.DocumentInvalid if not""" |
| 38 | assert xml_str or (xml_doc is not None) |
| 39 | if xml_str: |
| 40 | xml_doc = etree.fromstring(xml_str) |
| 41 | |
| 42 | try: |
| 43 | rng_validator.assertValid(xml_doc) |
| 44 | return True |
| 45 | except DocumentInvalid: |
| 46 | if not quiet: |
| 47 | xml_str = xml_str if xml_str else etree.tounicode(xml_doc, pretty_print=True) |
| 48 | log.error(f"Error validating report document:\n\n{xml_str}\n{rng_validator.error_log}\n") |
| 49 | raise |
| 50 | |
| 51 | |
| 52 | def conv_attrib(v: t.Any) -> t.Optional[str]: |