Expat - how to UseForeignDTD

B

B Mahoney

I have a simple Kid template document:

<?xml version='1.0' encoding='utf-8'?>
<?python
import time
title = "A Kid &anything; Template"
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#".... (snip)
</html>

This runs as expected but now I would like to load a DTD without
tampering with this xml file

In the expat parser __init__ after setting other handlers
for parser, I have added:
parser.ExternalEntityRefHandler = self._ExternalEntityRefHandler
parser.UseForeignDTD(1) (also tried True)

Which I understand at some point will call
self._ExternalEntityRefHandler
with None for args and I must have code to get this other dtd.
I have done regular ExternalEntityRefHandlers before.

As required, these two lines occur before my Parse() call.
Perhaps I misunderstand the sequence, or need something more in my
xml file, but my _ExternalEntityRefHandler is never called. The
process behaves as if I never added these two lines.

Help?
 
B

B Mahoney

I needed to set Entity Parsing, such as

parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_ALWAYS )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top