XML.com: XML From the Inside Out

XML.comWebServices.XML.comO'Reilly Networkoreilly.com
  Articles | Weblogs | Newsletter | Safari Bookshelf
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:


Contact Us | Our Mission | Privacy Policy | Advertise With Us | | Submissions Guidelines
Copyright © 2008 O'Reilly Media, Inc. | (707) 827-7000 / (800) 998-9938