[XML-SIG] 0.6.4: another problem with building DOM using validating parser
scott snyder
scott snyder <snyder@fnal.gov>
Fri, 02 Mar 2001 20:29:41 CST
hi -
Here's another problem with building DOM trees from XML with the validating
parser with 0.6.4.
--------------------------------------------------------------------
from xml.dom.ext.reader.Sax2 import FromXmlFile
f = open ('test5.xml', 'w')
f.write ("""<?xml version="1.0"?>
<!DOCTYPE configuration [
<!ENTITY testscrap SYSTEM "testscrap">
<!ELEMENT configuration EMPTY>
]>
<configuration/>
""")
f.close()
doc = FromXmlFile ('test5.xml', None, 1)
print doc
--------------------------------------------------------------------
When i run this:
$ python read5.py
Traceback (innermost last):
File "read5.py", line 14, in ?
doc = FromXmlFile ('test5.xml', None, 1)
File "xml/dom/ext/reader/Sax2.py", line 330, in FromXmlFile
saxHandlerClass, parser)
File "xml/dom/ext/reader/Sax2.py", line 315, in FromXmlStream
return reader.fromStream(stream, ownerDocument)
File "xml/dom/ext/reader/Sax2.py", line 301, in fromStream
self.parser.parse(s)
File "xml/sax/drivers2/drv_xmlproc.py", line 90, in parse
parser.read_from(source.getByteStream(), bufsize)
File "xml/parsers/xmlproc/xmlval.py", line 104, in read_from
self.parser.read_from(file,bufsize)
File "xml/parsers/xmlproc/xmlutils.py", line 137, in read_from
self.feed(buf)
File "xml/parsers/xmlproc/xmlutils.py", line 185, in feed
self.do_parse()
File "xml/parsers/xmlproc/xmlproc.py", line 104, in do_parse
self.parse_doctype()
File "xml/parsers/xmlproc/xmlproc.py", line 482, in parse_doctype
self.parse_internal_dtd()
File "xml/parsers/xmlproc/xmlproc.py", line 532, in parse_internal_dtd
self.handle_internal_dtd(line,lb,self.get_region()[:-last_part_size])
File "xml/parsers/xmlproc/xmlproc.py", line 544, in handle_internal_dtd
p.feed(int_dtd)
File "xml/parsers/xmlproc/xmlutils.py", line 185, in feed
self.do_parse()
File "xml/parsers/xmlproc/dtdparser.py", line 251, in do_parse
self.parse_entity()
File "xml/parsers/xmlproc/dtdparser.py", line 341, in parse_entity
self.dtd_consumer.new_external_entity(ent_name,pub_id,sys_id,ndata)
File "xml/parsers/xmlproc/xmldtd.py", line 151, in new_external_entity
self.dtd_listener.new_external_entity(ent_name,pubid,sysid,ndata)
File "xml/sax/drivers2/drv_xmlproc.py", line 239, in new_external_entity
ndata)
TypeError: too many arguments; expected 4, got 5
This seems to work around the problem, though i think it's probably not
the correct fix.
*** xml/dom/ext/reader/Sax2.py-orig2 Fri Mar 2 20:10:52 2001
--- xml/dom/ext/reader/Sax2.py Fri Mar 2 20:23:31 2001
***************
*** 255,262 ****
self._ownerDoc.getDocumentType().getNotations().setNamedItem(new_notation)
return
! def unparsedEntityDecl (self, publicId, systemId, notationName):
! new_notation = self._ownerDoc.getFactory().createEntity(self._ownerDoc, publicId, systemId, notationName)
self._ownerDoc.getDocumentType().getEntities().setNamedItem(new_notation)
return
--- 255,264 ----
self._ownerDoc.getDocumentType().getNotations().setNamedItem(new_notation)
return
! def unparsedEntityDecl (self, name, publicId, systemId, ndata):
! if not self._ownerDoc:
! return
! new_notation = self._ownerDoc.getFactory().createEntity(self._ownerDoc, publicId, systemId, name)
self._ownerDoc.getDocumentType().getEntities().setNamedItem(new_notation)
return