XML partial validation.

Stefan Behnel stefan.behnel-n05pAM at web.de
Fri Dec 14 02:59:18 EST 2007


José Rui Faustino de Sousa wrote:
> I am writing a text to XML parser that as to be easily extensible (via 
> new text format plug-ins) and modifiable if the XML format used changes.
> 
> Since the text order does not match the XML document order I have to use 
> a package that allows DOM-like handling of XML (elementtree for 
> instance).
> 
> The XML DTD is still (and most likelly will be) in a state of evolution.
> 
> To make life much easier for future developers what I really needed was 
> some package that implemented something like DOM level 3 XML partial 
> validation.
> 
> There seems to be already something implemented in PyXML (at least the 
> Validition-Err exception is there) but there is no documentation and I 
> can not figure how to turn partial validation on.

lxml supports RelaxNG and XMLSchema besides DTDs, you might have more luck
with those, especially since they are XML, so you can work on the schema
documents and extract the sections that are relevant for a specific XML fragment.

lxml is compatible with the ElementTree API, so you can reuse the ET code you
already have.

Stefan



More information about the Python-list mailing list