Skip to content
Advertisement

No DTD validation and XInclude resolution when using Saxon C HE with Python

I have a question about the Saxon C HE version for Python. After the successful installation I tried some examples where I executed XSLT transformations. These all worked.

However, when I parse an XML file, no DTD validation is performed during parsing and the XIncludes are not resolved. I have tried many things, however it is not possible for me to solve this problem. I hope someone can show me and explain my error.

Attached is an example which should show an error with intent when a DTD validation is done because there is no element with the name FOU in the DTD. When I run the script then it creates a Result.xml file and both the erroneous FOU element is present and the XInclude which is not resolved.

I am aware that it is easy to do this with lxml, however I would like to know how it works with the Saxon parser.

XML Master:

JavaScript

XML Include:

JavaScript

DTD:

JavaScript

Python Script:

JavaScript

Advertisement

Answer

You should be able to set the xi and dtd configuration properties to “on”.

JavaScript

However, the only way I could get it to work was if I removed the xpointer from the xinclude. I didn’t have time to research why this isn’t working.

It also doesn’t appear that parse_xml() does any validation or xinclude resolution, but it did happen on the transform (set dtd validation to “off” or to “recover” to get Result.xml).

Here’s the modified version of your Python that I used to test…

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement