def declare_valid(view): """Declare the document valid. Remove any highlight regions and indicate validity in status bar.""" view.erase_regions(constants.PLUGIN_NAME) vu.set_status(view, messages.VALID_MARKUP) vu.reset_status(view) return True
def validate(view, document, validator): try: validator.assertValid(document) return declare_valid(view) except etree.DocumentInvalid as e: if type(validator) == isoschematron.Schematron: message = _get_schematron_error_message(e) else: message = e return vu.show_error(view, message, validator.error_log[0]) except OSError: vu.set_status(view, messages.SCHEMA_RESOLVE_ERROR % id) return False
def format_region(view, region, **kwargs): if vu.is_eligible(view): try: parser = parsetools.get_parser(view, encoding=encodings.UTF8, remove_blank_text=True, recover=True) markup = parsetools.parse_string(view, parser, view.substr(region)) return format_markup(markup, view, **kwargs) except etree.XMLSyntaxError: vu.set_status(view, messages.NOT_WELL_FORMED_XML) vu.reset_status(view)