source: wsdl/validate.py @ d0912be

compt_changesinfo-ops
Last change on this file since d0912be was 9ecda47, checked in by Ted Faber <faber@…>, 14 years ago

Bad error handling (d'oh!)

  • Property mode set to 100644
File size: 610 bytes
Line 
1#!/usr/local/bin/python
2
3import sys
4try:
5    import lxml.etree
6except ImportError:
7    sys.exit("%s requires the lxml library" % sys.argv[0])
8
9if len(sys.argv) == 3:
10    schema_fn = sys.argv[1]
11    doc_fn = sys.argv[2]
12else:
13    sys.exit("Usage %s schema document" % sys.argv[0])
14
15
16try:
17    validator = lxml.etree.XMLSchema(lxml.etree.parse(schema_fn))
18    doc = lxml.etree.parse(doc_fn)
19    validator.assertValid(doc)
20    print "%s is valid (based on %s)" % (doc_fn, schema_fn)
21except EnvironmentError, e:
22    sys.exit("%s" % e)
23except lxml.etree.DocumentInvalid, e:
24    sys.exit("Validation failed: %s" % e)
Note: See TracBrowser for help on using the repository browser.