|
From: David H. <dt...@gm...> - 2005-08-11 14:52:29
|
If you're interested I've almost finished writing an implementation of
the xml.dom API which acts as a thin wrapper for the Java libraries.=20
It's almost done (got to finish testing / documenting) and I was
planning to offer it to the Jython team if they are interested in
incorporating it into the official distribution, though it would
require the xerces jars for anyone using a jdk < 1.4.
The __init__.py and domreg.py modules are taken straight from the
CPython distribution, my wrapper just acts as an available
implementation.
If you are interested I'll put what I've got so far up for download.
-Dave
On 8/11/05, Pekka Laukkanen <pek...@qe...> wrote:
> Hello all,
>=20
> I have simple Python code which can be used to create XML documents and
> now I'd need to get that working with Jython. The features I need are
> pretty basic -- creating an empty document, creating new elements,
> adding child elements, setting attributes and outputting the generated
> XML to a file. The code below shows all I need (the real code is of
> course somewhat more complicated).
>=20
> ---------[code]-------------------------------
> from xml.dom.minidom import Document
>=20
> doc =3D Document()
> root =3D doc.createElement("root")
> root.setAttribute("attr", "value")
> e1 =3D doc.createElement("e-1")
> e1.setAttribute("a1", "v1")
> e1.setAttribute("a2", "v2")
> e2 =3D doc.createElement("e-2")
> e21 =3D doc.createElement("e-2.1")
> e21.setAttribute("a", "v")
> e22 =3D doc.createElement("e-2.2")
> doc.appendChild(root)
> root.appendChild(e1)
> root.appendChild(e2)
> e2.appendChild(e21)
> e2.appendChild(e22)
>=20
> print doc.toprettyxml()
>=20
> ---------[output]-----------------------------
> <?xml version=3D"1.0" ?>
> <root attr=3D"value">
> <e-1 a1=3D"v1" a2=3D"v2"/>
> <e-2>
> <e-2.1 a=3D"v"/>
> <e-2.2/>
> </e-2>
> </root>
> ---------[end]--------------------------------
>=20
>=20
> I know that XML modules shipped with Jython 2.1 are a bit buggy and I
> also noticed that Jython 2.2 alpha 1 doesn't contain any XML modules. In
> general I'd like to move into 2.2 as soon as possible so I'm more
> interested about solutions working with it. I've studied the problem a
> bit and it seems that I have following two options with different pros
> and cons.
>=20
> 1) Install Python XML modules to Jython.
> + Current code should work as is.
> - Getting modules to work with Jython might require too much tweaking
> (see e.g.
> http://www.python.org/pycon/2005/papers/80/Server_side_jython%20V%201.2/T=
weaking_PyXML_with_Jython.html).
> The code must run on several machines and tweaking them all doesn't
> sound too tempting.
>=20
> 2) Use Java XML libraries instead of Python ones
> + Should work in any machine where Jython is installed
> - Need to write new (duplicate) code and maintain it
>=20
> Can anyone here help making the decision? What have you done in similar
> situation and did it work out?
>=20
> Cheers,
> .peke
>=20
> PS: Thanks a lot for everyone involved with recent Jython development.
> We've been using 2.2a1 without major problems (reported a non-fatal
> regression with importing as a bug #1256506) and are waiting for
> subsequent releases.
> --
> Qentinel Oy, Pekka Laukkanen
> pek...@qe..., +358 40 7791909
> Tekniikantie 14, 02150 Espoo, Finland
> http://www.qentinel.com/
>=20
>=20
>=20
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practic=
es
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q=
A
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
|