Dear Kevin,
Thanks for your information. I was using Jython2.1+ (compiled a snapshot) and
Java 1.4.1_02-b06 on my WinXP Home Edition.
From your feedback, I updated them to Jython2.2a0 and Java java1.4.2-beta.
Then, the problem is solved. I don't know whether there is a bug or not (most
probably from Java). I have used my previous tools to develop quite some Jython
programs. This is the first time I encountered such a strange problem.
Again, thanks!
Best regards,
Jingzhao
--- Kevin Butler <jython-kbutler@...> wrote:
> > From: Jingzhao Ou <jasonou@...>
> >
> > I try to use the Java DOM parsers from Jython. The code is:
> >
> > ==================================================
> > from org.w3c.dom import *
> > from javax.xml.parsers import *
> >
> > class XMLParser:
> > def __init__(self, file_name):
> > factory = DocumentBuilderFactory.newInstance()
> > builder = factory.newDocumentBuilder()
> > doc = builder.parse(file_name)
> > self.process(doc.documentElement) <---- this is ok
> > self.process(doc.getElementsByTagName('paper')) <--- this causes the
> problem
> > ==================================================
> >
> > However, I got the following error:
> >
> > java.lang.IllegalAccessException: java.lang.IllegalAccessException: Class
> > org.python.core.PyReflectedFunction can not access a member of class
> > org.apache.crimson.tree.ParentNode with modifiers "public"
> >
> > If any of you have even use the DOM parser shipped with Java, do you mind
> > giving me some little help?
>
> Hmm. It works for me:
>
> ---asdf.py
> from org.w3c.dom import *
> from javax.xml.parsers import *
>
> class XMLParser:
> def __init__(self, file_name):
> factory = DocumentBuilderFactory.newInstance()
> builder = factory.newDocumentBuilder()
> doc = builder.parse(file_name)
> self.process(doc.documentElement)
> self.process(doc.getElementsByTagName('paper'))
>
> def process( self, element ):
> print "process element:", element
>
> XMLParser( "asdf.xml" )
> ---asdf.xml
> <object>
> <value>value</value>
> </object>
> --- output
> Jython 2.1 on java1.4.0_01-ea (JIT: null)
> Type "copyright", "credits" or "license" for more information.
> >>> import asdf
> process element: <object>
> <value>value</value>
> </object>
> process element: org.apache.crimson.tree.ParentNode$TagList@...
> >>>
>
>
> (the Crimson parser is included in JRE 1.4, in rt.jar)
>
> KB
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive? Does it
> help you create better code? SHARE THE LOVE, and help us help
> YOU! Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
|