blob: bbfc6d72c50cc564a259609462c0fa6dc3f350bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
|