[XML-SIG] Re: xmlproc, SAX and EntityResolver
uche.ogbuji@fourthought.com
uche.ogbuji@fourthought.com
Sun, 24 Jan 1999 16:48:41 -0700
This is a multipart MIME message.
--==_Exmh_-20107729380
Content-Type: text/plain; charset=us-ascii
> | Unfortunately, on preliminary testing it doesn't appear to work.
> | I'll work on an isolated test case and get back to you.
>
> Arh! I'm getting confused by all the different versions here. Sorry,
> you need this in xmlproc.py as well to have it call that method (just
> replace the existing method with this, hopefully this does not depend
> on other changes):
Thanks, but maybe there is yet a dependency, because it still doesn't work.
Here's a small test case. The SAX app, xml file and DTD are attached. I get
results from the startElement (of course), but not from any of the other
events.
--
Uche Ogbuji
FourThought LLC, IT Consultants
uche.ogbuji@fourthought.com (970)481-0805
Software engineering, project management, Intranets and Extranets
http://FourThought.com http://OpenTechnology.org
--==_Exmh_-20107729380
Content-Type: text/plain ; name="addr_book.dtd"; charset=us-ascii
Content-Description: addr_book.dtd
Content-Disposition: attachment; filename="addr_book.dtd"
<!ELEMENT ADDRBOOK (ENTRY*)>
<!ELEMENT ENTRY (NAME, ADDRESS, PHONENUM*, EMAIL)>
<!ATTLIST ENTRY
ID ID #REQUIRED
>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT ADDRESS (#PCDATA)>
<!ELEMENT PHONENUM (#PCDATA)>
<!ATTLIST PHONENUM
DESC CDATA #REQUIRED
>
<!ELEMENT EMAIL (#PCDATA)>
--==_Exmh_-20107729380
Content-Type: text/plain ; name="addr_book1.xml"; charset=us-ascii
Content-Description: addr_book1.xml
Content-Disposition: attachment; filename="addr_book1.xml"
<?xml version = "1.0"?>
<!DOCTYPE ADDRBOOK SYSTEM "addr_book.dtd" [
<!ENTITY xxx SYSTEM "Mein Kampf">
]>
<ADDRBOOK>
<ENTRY ID="pa">
<NAME>Pieter Aaron</NAME>
<ADDRESS>404 Error Way</ADDRESS>
<PHONENUM DESC="Work">404-555-1234</PHONENUM>
<PHONENUM DESC="Fax">404-555-4321</PHONENUM>
<PHONENUM DESC="Pager">404-555-5555</PHONENUM>
<EMAIL>pieter.aaron@inter.net</EMAIL>
</ENTRY>
<ENTRY ID="en">
<NAME>Emeka Ndubuisi</NAME>
<ADDRESS>42 Spam Blvd</ADDRESS>
<PHONENUM DESC="Work">767-555-7676</PHONENUM>
<PHONENUM DESC="Fax">767-555-7642</PHONENUM>
<PHONENUM DESC="Pager">800-SKY-PAGEx767676</PHONENUM>
<EMAIL>endubuisi@spamtron.com</EMAIL>
</ENTRY>
<ENTRY ID="vz">
<NAME>Vasia Zhugenev</NAME>
<ADDRESS>2000 Disaster Plaza</ADDRESS>
<PHONENUM DESC="Work">000-987-6543</PHONENUM>
<PHONENUM DESC="Cell">000-000-0000</PHONENUM>
<EMAIL>vxz@magog.ru</EMAIL>
</ENTRY>
</ADDRBOOK>
--==_Exmh_-20107729380
Content-Type: text/plain; name="test_doctype.py"; charset=us-ascii
Content-Description: test_doctype.py
Content-Disposition: attachment; filename="test_doctype.py"
Content-Transfer-Encoding: quoted-printable
import sys
from xml.sax import saxlib, saxexts, drivers
class test_doctype(saxlib.HandlerBase):
def unparsedEntityDecl (self, publicId, systemId, notationName):
print "unparsedEntityDecl", publicId, systemId, notationName
def resolveEntity (self, name, publicId, systemId):
print "entity", name, publicId, systemId
def startElement(self, name, attribs):
print "element", name, attribs
def warning(self, exception):
raise exception
def error(self, exception):
raise exception
def fatalError(self, exception):
raise exception
if __name__ =3D=3D "__main__":
parser =3D saxexts.XMLValParserFactory.make_parser()
handler =3D test_doctype()
parser.setDocumentHandler(handler)
parser.setDTDHandler(handler)
parser.setEntityResolver(handler)
parser.setErrorHandler(handler)
parser.parseFile(open("addr_book1.xml"))
--==_Exmh_-20107729380--