aboutsummaryrefslogtreecommitdiff
path: root/scripts/rpki/relaxng.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rpki/relaxng.py')
-rw-r--r--scripts/rpki/relaxng.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/rpki/relaxng.py b/scripts/rpki/relaxng.py
new file mode 100644
index 00000000..bbfc6d72
--- /dev/null
+++ b/scripts/rpki/relaxng.py
@@ -0,0 +1,24 @@
+# $Id$
+
+import lxml.etree
+
+class RelaxNG(lxml.etree.RelaxNG):
+ """
+ Minor customizations of lxml.etreeRelaxNG.
+ """
+
+ def __init__(self, filename):
+ """
+ Initialize a RelaxNG validator from a file.
+ """
+ lxml.etree.RelaxNG.__init__(self, lxml.etree.parse(filename))
+
+ def assertValid(self, doc):
+ """
+ Provide a bit more information on validation failures.
+ """
+ try:
+ lxml.etree.RelaxNG.assertValid(self, doc)
+ except lxml.etree.DocumentInvalid:
+ print self.error_log.last_error
+ raise