Problem with using xml with jython

Gautam gmulchan at hotmail.com
Wed Jul 18 16:34:22 EDT 2001


Hi,
   I am trying to run a simple program shown below with jython. It
runs with python successfully but throws the following exception when
run with jython. Can someone point out the problem.
   I am using python 2.0. on win2k. I downloaded the xml package very
recently.

Thx

program starts here 
--------------------------------
import sys

from xml.sax import saxutils
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces

#print sys.modules
    
file='test.xml'

class FindIssue(saxutils.DefaultHandler):
    def __init__(self, title, number):
        self.search_title, self.search_number = title, number

    def startElement(self,name,attrs):
        if name != 'comic' : return

        title = attrs.get('title', None)
        number = attrs.get('number',None)
        if title == self.search_title and number ==
self.search_number:
            print title, '#'+str(number), 'found'
        
if __name__ == '__main__':
    parser = make_parser()
 #   parser.setFeature(feature_namespaces,0)

    dh = FindIssue('Sandman', '62')
    parser.setContentHandler(dh)
    parser.parse(file)

----------------------------------------------------------

The exception in jython is :

C:\pythoncode\xmltest>C:\jython-2.0\jython trial.py
Traceback (innermost last):
  File "trial.py", line 24, in ?
  File "C:\jython-2.0\_xmlplus\sax\sax2exts.py", line 34, in
make_parser
  File "C:\jython-2.0\_xmlplus\sax\saxexts.py", line 75, in
make_parser
KeyError: xml.sax.drivers2.drv_pyexpat



More information about the Python-list mailing list