jython lacks working xml processing modules?

Alan Kennedy alanmk at hotmail.com
Fri Nov 21 06:07:19 EST 2003


[Jane Austine]
> I'm trying to parse an xml file with jython (not through java parsers
> like xerces).
> 
> I tried minidom in jython 2.1 and 2.2a but all failed.

It's quite likely that your documents contained namespaces. The only
parser supported in jython is "xmlproc", because it is pure python.
However, "xmlproc" has some significant bugs in relation to namespace
processing, IIRC from the last time I looked at it.

> What can I do? 

1. Use a Java SAX2 parser, write a jython ContentHandler for it, build
a Minidom from the events.
2. Use a Java DOM processor (DOM4J, JDOM, etc), and let it build a DOM
for you.

It would probably be easier if you could give an outline of what you
are trying to achieve. For example, do you really need to build an
object model? Do you need to use xpath? Do you need to validate
structures? Etc, etc.

> The last resort would be using java parsers. Then how
> can I use them like python xml parsers? It seems like javadom and
> javasax has something to do, but I don't know how.

If you want to know about using SAX events to build object models,
check this old thread on c.l.py.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=mailman.1058894673.16506.python-list%40python.org

If you have any specific questions or face any specific problems, post
some details.

regards,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list