PyXML, Sax, error in processing external entity reference

Bennie rotzjes at wanadoo.nl
Fri Feb 27 00:53:10 CET 2004


David Dorward wrote:
> I'm attempting to read an XHTML 1.1 file[1], perform some DOM manipulation,
> then write the results to a different file.
> 
> I've found myself rather stuck at the first hurdle.
> 
> I have the following:
> 
> from xml.dom.ext.reader import Sax2
> reader = Sax2.Reader()
> f = open('dorward.me.uk/sitemap.html', 'r')
> doc = reader.fromStream(f)
> 
> (dorward.me.uk/sitemap.html being a local copy of
> http://dorward.me.uk/sitemap.html)
> 
> ... which outputs the following:
> 
> Traceback (most recent call last):
>   File "x.py", line 4, in ?
>     doc = reader.fromStream(f)
>   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py",
> line 372, in fromStream
>     self.parser.parse(s)
>   File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py", line
> 109, in parse
>     xmlreader.IncrementalParser.parse(self, source)
>   File "/usr/lib/python2.3/site-packages/_xmlplus/sax/xmlreader.py", line
> 123, in parse
>     self.feed(buffer)
>   File "/usr/lib/python2.3/site-packages/_xmlplus/sax/expatreader.py", line
> 220, in feed
>     self._err_handler.fatalError(exc)
>   File "/usr/lib/python2.3/site-packages/_xmlplus/dom/ext/reader/Sax2.py",
> line 340, in fatalError
>     raise exception
> xml.sax._exceptions.SAXParseException:
> http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-notations-1.mod:115:0:
> error in processing external entity reference
> 
> I'm not sure where I should proceed from here. Is it a bug in my code? In
> PyXML? In the DTD itself? What should I do next?
> 
> Thanks.
> 
> [1] Actually, lots of files, but one at a time.
> 
I think you need a parser
 >>>import xml.sax
 >>>parser = xml.sax.make_parser()
 >>>file = "dorward.me.uk/sitemap.html"
 >>>parser.parse(file)

How furder I don't now, I'am stuck to!

Try the 'http://pyxml.sourceforge.net/topics/howto/xml-howto.html'site.

Bennie,



More information about the Python-list mailing list