compt_changesinfo-ops
Last change
on this file since 9294673 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
|
Rev | Line | |
---|
[549830d] | 1 | #!/usr/local/bin/python |
---|
| 2 | |
---|
| 3 | import sys |
---|
| 4 | try: |
---|
| 5 | import lxml.etree |
---|
| 6 | except ImportError: |
---|
| 7 | sys.exit("%s requires the lxml library" % sys.argv[0]) |
---|
| 8 | |
---|
| 9 | if len(sys.argv) == 3: |
---|
| 10 | schema_fn = sys.argv[1] |
---|
| 11 | doc_fn = sys.argv[2] |
---|
| 12 | else: |
---|
[9ecda47] | 13 | sys.exit("Usage %s schema document" % sys.argv[0]) |
---|
[549830d] | 14 | |
---|
| 15 | |
---|
| 16 | try: |
---|
| 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) |
---|
| 21 | except EnvironmentError, e: |
---|
| 22 | sys.exit("%s" % e) |
---|
| 23 | except lxml.etree.DocumentInvalid, e: |
---|
| 24 | sys.exit("Validation failed: %s" % e) |
---|
Note: See
TracBrowser
for help on using the repository browser.