Problem with using xml with jython

Gautam gmulchan at hotmail.com
Wed Jul 18 20:40:43 EDT 2001


i fixed the problem by using
parser = make_parser('xml.sax.drivers2.drv_xmlproc')
instead of
parser = make_parser()

Thx

gmulchan at hotmail.com (Gautam) wrote in message news:<f35f1426.0107181234.3406817e at posting.google.com>...
> 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