Select Git revision
01-devices.py
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
validator.py 910 B
from lxml import etree
def validate(xmlpath, xsdpath):
'''validates given xml file against given xsd file'''
with open(xsdpath) as xsd:
xmlschema_doc = etree.parse(xsd)
xmlschema = etree.XMLSchema(xmlschema_doc)
with open(xmlpath) as xml:
doc = etree.parse(xml)
valid = xmlschema.validate(doc)
if not valid:
try:
xmlschema.assertValid(doc)
except Exception as err:
print err
return valid
#expose a main method in this lib module which can be used by external programs
#or by the bin/validatesip 'program'
def main(argv):
#do the proper calls to the SIP API
# parse cmdline args etc
try:
xml = argv[0]
xsd = argv[1]
validate(xml, xsd)
except Exception as err:
print "An error occurred:"
print err