Sign In/My Account | View Cart  
advertisement

Article:
 Gems from the Mines: 2002 to 2003
Subject: lxml Relax NG
Date: 2005-03-04 03:50:28
From: Martijn Faassen

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.


Previous Message Previous Message   Next Message Next Message


Sponsored By: