Guest User

Untitled

a guest
Feb 11th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. def validate(self):
  2.  
  3. # считывание файла схемы
  4. with open(self.xsd_path, 'r') as schema_file:
  5. schema_to_check = schema_file.read()
  6. parser = etree.XMLParser(encoding='cp1251')
  7. xmlschema_doc = etree.parse(StringIO(schema_to_check), parser)
  8. xmlschema = etree.XMLSchema(xmlschema_doc)
  9.  
  10. # здесь получаю результат валидации TRUE или FALSE
  11. doc = etree.parse(self.xml_path, parser)
  12. return xmlschema.validate(doc)
Add Comment
Please, Sign In to add comment