title: getting expat to use .dtd for entity replacement in python
body: <p>I'm trying to read in an xml file which looks like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!DOCTYPE dblp SYSTEM "dblp.dtd"&gt;
  &lt;dblp&gt;
  &lt;incollection&gt;
  &lt;author&gt;Jos&amp;eacute; A. Blakeley&lt;/author&gt;
  &lt;/incollection&gt;
  &lt;/dblp&gt;
  </code></pre>
  
  <p>The point that creates the problem looks is the</p>
  
  <pre><code>Jos&amp;eacute; A. Blakeley
  </code></pre>
  
  <p>part: The parser calls its character handler twice, once with "Jos", once with " A. Blakeley". 
  Now I understand this may be the correct behaviour if it doesn't know the eacute entity. However, this is defined in the dblp.dtd, which I have. I don't seem to be able to convince expat to use this file, though. All I can say is</p>
  
  <pre><code>p = xml.parsers.expat.ParserCreate()
  # tried with and without following line
  p.SetParamEntityParsing(xml.parsers.expat.XML_PARAM_ENTITY_PARSING_ALWAYS) 
  p.UseForeignDTD(True)
  f = open(dblp_file, "r")
  p.ParseFile(f)
  </code></pre>
  
  <p>but expat still doesn't recognize my entity. Why is there no way to tell expat which DTD to use? I've tried</p>
  
  <ul>
  <li>putting the file into the same directory as the XML</li>
  <li>putting the file into the program's working directory</li>
  <li>replacing the reference in the xml file by an absolute path</li>
  </ul>
  
  <p>What am I missing? Thx.</p>