|
I know this is still vaporware as I haven't made a release yet (but it works! Release forthcoming real soon now, I promise!), but lxml quite nicely exposes Relax NG functionalities from libxml2:
# make a relax NG object from some xml
relaxng_doc = lxml.etree.parse(someschemafile())
relaxng = lxml.etree.RelaxNG(relaxng_doc)
# now validate another file with it
doc = lxml.etree.parse(somexmlfile())
if relaxng.validate(doc):
print "it's valid!"
else:
print "it's not valid!"
The main important thing still missing from lxml is better error reporting, though.
|