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.Pass an Element Tree object to construct a XMLSchema validator: From version 2.3 on lxml features ISO-Schematron support built on the de-facto reference implementation of Schematron, the pure-XSLT-1.0 skeleton implementation.You'll get back True if the document is valid against the Relax NG schema, and False if not: Note that this error log is local to the Relax NG object.
You need one schema and two XML files to validate against the schema.
Schematron automatically converts these parameters to stylesheet parameters so you need not worry to set string parameters using quotes or to use XSLT.strparam().
If you ever need to pass an XPath as argument to the XSLT stylesheet you can pass in an etree.
This program validates the XML document against the schema successfully.
However, when the user selects the XML document catalog1.xml, validation fails for the book element in the lines containing more than one title element.