From: Sébastien B. <Seb...@en...> - 2008-07-14 15:13:46
|
Jim, I am using Java's org.xml.sax and not Jython's xml.sax. I made the code available at http://code.google.com/p/jython-elementtree. Only elementtree/ElementTree.py and elementtree/JythonHotfix.py are of interest. The other files are identical to what is found in the elementtree 1.3 alpha svn repository: http://svn.effbot.org/public/tags/elementtree-1.3a3-20070912/ I don't guarantee anything beyond the 'jython2.5a0 selftest.py' good score at this point ... I also guess that my ElementTree target version -- 1.3, still in alpha and not the one in Python 2.5 standard lib -- may be an issue for direct inclusion in Jython 2.5. However, if you feel that this work can be adapted for the Jython 2.5 standard library, please go ahead ! Regards, SB Jim Baker wrote: > to the list > > On Mon, Jul 14, 2008 at 3:29 PM, Jim Baker <jb...@zy... > <mailto:jb...@zy...>> wrote: > > This looks great. Supporting elementtree (as xml.etree) is a key > piece we want to see in Jython 2.5. Rewriting it to using SAX is > the right approach. The only challenge I have seen in porting code > that uses expat is that xml.sax does not include the error > reporting functionality seen in > Java's org.xml.sax.ext.LexicalHandler > and org.xml.sax.ext.DeclHandler. I would guess this accounts for > most of the remaining bugs you have. > > Ariane Paola was looking at a similar problem in porting genshi, > so it's possible that she has worked through these issues now. > > So I hope you will be able to contribute this work as a patch so > we can add to Jython. > > - Jim > > On Sat, Jul 12, 2008 at 8:46 PM, Sébastien Boisgérault > <Seb...@en... > <mailto:Seb...@en...>> wrote: > > > Hi all, > > I've been testing Jython 2.5 alpha 0 on a port of ElementTree > 1.3 alpha 3, slightly > adapted for Jython (expat replaced with SAX essentially). The > output of the doctests > run is attached: there are only 7 failures out of 343 tests > and at a first glance, there > are minor (error messages not being exactly the same, that > kind of thing). The 'stable' jython 2.2.1 had 36 errors and > one or two months ago, there was still 14 errors, some > of them being (hard) encoding issues. > > Consider this as a testimony of the very impressive progress > that has been made > in the development of Jython lately. Congratulations to > everyone involved ! > > Cheers, > > SB > > > > > > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 1050, in selftest.bug_200708_version > Failed example: > parser.version > Expected: > 'Expat 2.0.0' > Got: > 'J2SE 1.6.0' > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 948, in selftest.bug_xmltoolkit39 > Failed example: > tree.attrib > Expected: > {u'\xe4ttr': u'v\xe4lue'} > Got: > {'\xe4ttr': 'v\xe4lue'} > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 1040, in selftest.bug_xmltoolkit55 > Failed example: > e = ElementTree.XML("<!DOCTYPE doc SYSTEM > 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>") > Expected: > Traceback (most recent call last): > ParseError: undefined entity &ldots;: line 1, column 36 > Got: > Traceback (most recent call last): > File "/usr/local/jython2.5a0/Lib/doctest.py", line 1235, > in _DocTestRunner__run > exec compile(example.source, filename, "single", > File "<doctest selftest.bug_xmltoolkit55[0]>", line 1, in > <module> > e = ElementTree.XML("<!DOCTYPE doc SYSTEM > 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>") > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/ElementTree.py", > line 1226, in XML > return parser.close() > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/JythonHotfix.py", > line 159, in close > self.parse(input_source) > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/JythonHotfix.py", > line 147, in parse > self._reader.parse(text) > java.io.FileNotFoundException: > java.io.FileNotFoundException: > /home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/doc.dtd > (No such file or directory) > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 535, in selftest.entity > Failed example: > ElementTree.XML("<document>&entity;</document>") > Expected: > Traceback (most recent call last): > ParseError: undefined entity: line 1, column 10 > Got: > Traceback (most recent call last): > File "/usr/local/jython2.5a0/Lib/doctest.py", line 1235, > in _DocTestRunner__run > exec compile(example.source, filename, "single", > File "<doctest selftest.entity[0]>", line 1, in <module> > ElementTree.XML("<document>&entity;</document>") > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/ElementTree.py", > line 1226, in XML > return parser.close() > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/JythonHotfix.py", > line 170, in close > raise error > ParseError: undefined entity: line 1, column 18 > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 539, in selftest.entity > Failed example: > ElementTree.XML(ENTITY_XML) > Expected: > Traceback (most recent call last): > ParseError: undefined entity &entity;: line 5, column 10 > Got: > Traceback (most recent call last): > File "/usr/local/jython2.5a0/Lib/doctest.py", line 1235, > in _DocTestRunner__run > exec compile(example.source, filename, "single", > File "<doctest selftest.entity[1]>", line 1, in <module> > ElementTree.XML(ENTITY_XML) > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/ElementTree.py", > line 1226, in XML > return parser.close() > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/JythonHotfix.py", > line 159, in close > self.parse(input_source) > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/elementtree/JythonHotfix.py", > line 147, in parse > self._reader.parse(text) > java.io.FileNotFoundException: > java.io.FileNotFoundException: > /home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/user-entities.xml > (No such file or directory) > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 553, in selftest.error > Failed example: > error("<tag>&foo;</tag>").position > Expected: > (1, 5) > Got: > (1, 10) > ********************************************************************** > File > "/home/boisgera/SANDBOX/ELEMENTREE-ALPHA-1.3a3-20070912-PREVIEW/elementtree-1.3/selftest.py", > line 555, in selftest.error > Failed example: > error("foobar<").position > Expected: > (1, 6) > Got: > (1, 0) > ********************************************************************** > 5 items had failures: > 1 of 4 in selftest.bug_200708_version > 1 of 12 in selftest.bug_xmltoolkit39 > 1 of 1 in selftest.bug_xmltoolkit55 > 2 of 2 in selftest.entity > 2 of 3 in selftest.error > ***Test Failed*** 7 failures. > 336 tests ok. > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source > project, > along with a healthy diet, reduces your potential for chronic > lameness > and boredom. Vote Now at > http://www.sourceforge.net/community/cca08 > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > <mailto:Jyt...@li...> > https://lists.sourceforge.net/lists/listinfo/jython-dev > > > > > -- > Jim Baker > jb...@zy... <mailto:jb...@zy...> > > > > > -- > Jim Baker > jb...@zy... <mailto:jb...@zy...> |