If you want to validate an XML document against a DTD that is not referenced by the document itself, you can use the keyword argument to parse from a file.
This also enables correct handling of include files from within the Relax NG parser.
If you ever need to pass an XPath as argument to the XSLT stylesheet you can pass in an etree.
lxml also provides support for ISO-Schematron, based on the pure-XSLT skeleton implementation of Schematron: There is also basic support for The parser in lxml can do on-the-fly validation of a document against a DTD or an XML schema.
The DTD is retrieved automatically based on the DOCTYPE of the parsed document.
That is, the validation feature overrides the expand entity references feature.
The five predefined references— The following two methods determine whether the parsers produced by this factory will generate comment nodes for comments seen in the input document.
It will only contain log entries that appeared during the validation.
Similar to XSLT, there's also a less efficient but easier shortcut method to do one-shot Relax NG validation: lxml.etree also has XML Schema (XSD) support, using the class lxml.etree. The API is very similar to the Relax NG and DTD classes.
CDATA sections should not be treated differently than any other text.
Whether or not certain text is written in a CDATA section should be purely a matter of syntax sugar for human convenience, not anything that has any effect on the data model. If a parser is validating, then this it will expand entity references, even if this feature is set to false.
Pass an Element or Element Tree object to construct a Schematron validator: .
Schematron automatically converts these parameters to stylesheet parameters so you need not worry to set string parameters using quotes or to use XSLT.strparam().
The default, false, means that comment nodes will be produced. False means include comments, and true means don’t include comments.