XML (XHTML) character entities and PxXml

Martin v. Löwis loewis at informatik.hu-berlin.de
Wed May 8 12:36:11 EDT 2002


andrew at acooke.org (andrew cooke) writes:

> > That is supposed to work; you'll need to provide details to analyse
> > what went wrong.
[...]
> Now at work, here are the details:

I see. That turns out to be a problem in PyXML; please try the
attached patch (to expatreader).

With that, your entity resolver is first asked to resolve the DTD. You
don't have to resolve this to the true DTD, since expat still won't
perform validation. Instead, you could resolve this to some local file
that just contains the entity definitions.

I personally had some problems with expat processing the XHTML DTD,
which I haven't analysed further. Removing large-enough chunks from
the DTD eventually allowed me to process your example successfully.

HTH,
Martin

Index: expatreader.py
===================================================================
RCS file: /cvsroot/pyxml/xml/xml/sax/expatreader.py,v
retrieving revision 1.21
diff -u -r1.21 expatreader.py
--- expatreader.py	5 Apr 2002 17:06:33 -0000	1.21
+++ expatreader.py	8 May 2002 16:18:01 -0000
@@ -250,6 +250,7 @@
 #         self._parser.DefaultHandlerExpand =
 #         self._parser.NotStandaloneHandler =
         self._parser.ExternalEntityRefHandler = self.external_entity_ref
+        self._parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
 
         self._parsing = 0
         self._entity_stack = []




More information about the Python-list mailing list