source: wsdl/validate.py @ 549830d

axis_examplecompt_changesinfo-ops
Last change on this file since 549830d was 549830d, checked in by Ted Faber <faber@…>, 13 years ago

Set up a makefile to create a standalone version of topdl.xsd (called
topdl_stand.xsd) that can be used to validate topdl files.

validate.py uses lxml to validate such files locally, and fails gracefully without lxml.

  • Property mode set to 100644
File size: 595 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.die("Usage %s schema document")
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.