From 7ed3ca7909edc5bc5f755770c860babf3ab36d52 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 3 Aug 2007 15:27:57 +0000 Subject: Checkpoint svn path=/scripts/irbe-cli.py; revision=823 --- scripts/rpki/relaxng.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/rpki/relaxng.py (limited to 'scripts/rpki/relaxng.py') 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 -- cgit v1.2.3