All you have to do is use a parser that has DTD validation enabled: option, which loads the DTD and weaves attribute default values into the document.Again, no validation is performed unless explicitly requested.(If a combination is not supported by a particular implementation, it is required to generate a factory configuration error.) Although a full treatment of XML Schema is beyond the scope of this tutorial, this section shows you the steps you take to validate an XML document using an existing schema written in the XML Schema language.
The reason is that XML software should be small, fast, and compatible.
HTML browsers are allowed to display HTML documents with errors (like missing end tags). A "well formed" XML document is not the same as a "valid" XML document. In addition, it must conform to a document type definition.
Apart from the built-in DTD support in parsers, lxml currently supports three schema languages: DTD, Relax NG and XML Schema.
All three provide identical APIs in lxml, represented by validator classes with the obvious names.
Validation is the process of checking a document against a DTD (more generally against a set of construction rules).