But if you are willing to limit where you put XIncludes in your document, then you can create a DTD customization to support your usage.
You have to declare the XInclude elements and then add them to the content models of certain elements.
You can read more about JSON Schema at Internally Is Valid uses Json Validating Reader to perform the JSON Schema validation.
JSON Schema is used to validate the structure and data types of a piece of JSON, similar to XML Schema for XML.
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.
This is provided by the lxml.isoschematron package that implements the Schematron class, with an API compatible to the other validators'.
Even if you resolve your XIncludes, you may still run into a problem with element to the Doc Book DTD. It has to be added into content models of elements as it would appear in documents.
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.The The usage of validation phases is a unique feature of ISO-Schematron and can be a very powerful tool e.g. for establishing validation stages or to provide different validators for different "validation audiences". It can validate the including and included files separately, but it cannot validate the merged content in one step.So validation with Xerces requires adding the element to the Doc Book DTD to avoid validation errors, as described in the next section.