diff --git a/mephi.xml b/mephi.xml new file mode 100644 index 0000000..ddc738a --- /dev/null +++ b/mephi.xml @@ -0,0 +1,23 @@ + + + + + + Anisimova + Artemyev + Bubenko + Dzheloukhova + Zamanov + Miheev + Pivovarov + Samsonov + Sidorova + Solovyeva + Tarmazakov + Titorenko + Shtanko + + + + diff --git a/mephi.xsd b/mephi.xsd new file mode 100644 index 0000000..96be01b --- /dev/null +++ b/mephi.xsd @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/validxsd.py b/validxsd.py new file mode 100755 index 0000000..0638244 --- /dev/null +++ b/validxsd.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +#-*- coding: UTF-8 -*- + +import optparse, libxml2, sys + +def schema_validate(xml_file, xsd_file): + ctxt = libxml2.schemaNewParserCtxt(xsd_file) + schema = ctxt.schemaParse() + validationCtxt = schema.schemaNewValidCtxt() + res = validationCtxt.schemaValidateFile(xml_file, 0) + if res != 0: + print "VALIDATION FAILED" + else: + print "VALIDATED" + return res + + +def main(argv): + op = optparse.OptionParser(description = U"Проверка на соответствие XSD", prog="xsd", version="0.1", usage=U"%prog") + op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") + op.add_option("-s", "--xsd", dest="xsd", help=U"XSD документ", metavar="XSD_FILE") + + options, arguments = op.parse_args() + if options.xml and options.xsd: + schema_validate(options.xml, options.xsd) + else: + op.print_help() + +if __name__=='__main__': + main(sys.argv)