23 from lxml
import etree
27 def __init__(self,xsd_path):
28 xmlschema_doc = etree.parse(xsd_path)
29 self.
xmlschema = etree.XMLSchema(xmlschema_doc)
31 def validate(self, xml_path) :
32 xml_doc = etree.parse(xml_path)
36 print (error.message, error.line, error.column)
41 if len (sys.argv) != 3 :
42 print (
'Usage: python validateDataModel.py <XML_FILE_PATH> <XSD_FILE_PATH>')
43 raise Exception (
'Invalid arguments to validateDataModel.py')
45 xml_file_path=sys.argv[1]
46 xsd_file_path=sys.argv[2]
49 if validator.validate(xml_file_path):
50 print(
'Data-model is valid')
52 print(
'data-model.xml is not valid');
53 raise Exception(
'data-model.xml is not matching with the cwmp schema')