|
From: Pekka L. <pek...@qe...> - 2005-08-11 13:01:03
|
Hello all,
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).
---------[code]-------------------------------
from xml.dom.minidom import Document
doc = Document()
root = doc.createElement("root")
root.setAttribute("attr", "value")
e1 = doc.createElement("e-1")
e1.setAttribute("a1", "v1")
e1.setAttribute("a2", "v2")
e2 = doc.createElement("e-2")
e21 = doc.createElement("e-2.1")
e21.setAttribute("a", "v")
e22 = doc.createElement("e-2.2")
doc.appendChild(root)
root.appendChild(e1)
root.appendChild(e2)
e2.appendChild(e21)
e2.appendChild(e22)
print doc.toprettyxml()
---------[output]-----------------------------
<?xml version="1.0" ?>
<root attr="value">
<e-1 a1="v1" a2="v2"/>
<e-2>
<e-2.1 a="v"/>
<e-2.2/>
</e-2>
</root>
---------[end]--------------------------------
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.
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/Tweaking_PyXML_with_Jython.html).
The code must run on several machines and tweaking them all doesn't
sound too tempting.
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
Can anyone here help making the decision? What have you done in similar
situation and did it work out?
Cheers,
.peke
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/
|
|
From: Jeff E. <jem...@fr...> - 2005-08-11 14:15:12
|
If you used the Java dom API from Jython, you would
find the code below identical except for
the document instantiation and printing. I think
you could write a function to abstract those differences
and use the same codebase.
Pekka Laukkanen wrote:
> ---------[code]-------------------------------
> from xml.dom.minidom import Document
>
> doc = Document()
> root = doc.createElement("root")
> root.setAttribute("attr", "value")
> e1 = doc.createElement("e-1")
> e1.setAttribute("a1", "v1")
> e1.setAttribute("a2", "v2")
> e2 = doc.createElement("e-2")
> e21 = doc.createElement("e-2.1")
> e21.setAttribute("a", "v")
> e22 = doc.createElement("e-2.2")
> doc.appendChild(root)
> root.appendChild(e1)
> root.appendChild(e2)
> e2.appendChild(e21)
> e2.appendChild(e22)
>
> print doc.toprettyxml()
> ---------[end]--------------------------------
> 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
|
|
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
>
|
|
From: Pekka L. <pek...@qe...> - 2005-08-11 15:26:40
|
David Hume wrote: > 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. > 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. I'm extremely interested. A wrapper like that is a great idea and would make "porting" Python XML code to Jython trivial. If you put the code available I promise to report back all possible problems we found. TIA, .peke -- Qentinel Oy, Pekka Laukkanen pek...@qe..., +358 40 7791909 Tekniikantie 14, 02150 Espoo, Finland http://www.qentinel.com/ |
|
From: David H. <dt...@gm...> - 2005-08-11 16:12:33
|
http://www.westoya.com/~rowth/javadom-0.1.tar.gz Feedback welcome -Dave On 8/11/05, Pekka Laukkanen <pek...@qe...> wrote: > David Hume wrote: > > 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. > > 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. >=20 > I'm extremely interested. A wrapper like that is a great idea and would > make "porting" Python XML code to Jython trivial. If you put the code > available I promise to report back all possible problems we found. >=20 > TIA, > .peke > -- > Qentinel Oy, Pekka Laukkanen > pek...@qe..., +358 40 7791909 > Tekniikantie 14, 02150 Espoo, Finland > http://www.qentinel.com/ >=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 >=20 > |
|
From: Ivan H. <pil...@ya...> - 2006-04-11 08:45:55
|
Dear David,
i have the same problem as you've discussed here in this thread.
i would like to test your wrapper also, but the link below is not
working for me.
can you point me to the right place, please?
Thursday, August 11, 2005, 6:12:21 PM, you wrote:
DH> http://www.westoya.com/~rowth/javadom-0.1.tar.gz
DH> Feedback welcome
DH> -Dave
DH> On 8/11/05, Pekka Laukkanen <pek...@qe...> wrote:
>> David Hume wrote:
>> > 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.
>> > 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.
>>
>> I'm extremely interested. A wrapper like that is a great idea and would
>> make "porting" Python XML code to Jython trivial. If you put the code
>> available I promise to report back all possible problems we found.
>>
>> TIA,
>> .peke
>> --
>> Qentinel Oy, Pekka Laukkanen
>> pek...@qe..., +358 40 7791909
>> Tekniikantie 14, 02150 Espoo, Finland
>> http://www.qentinel.com/
>>
>>
>> -------------------------------------------------------
>> SF.Net email is Sponsored by the Better Software Conference & EXPO
>> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
>> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
>> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
>> _______________________________________________
>> Jython-users mailing list
>> Jyt...@li...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
DH> -------------------------------------------------------
DH> SF.Net email is Sponsored by the Better Software Conference & EXPO
DH> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
DH> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
DH> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
DH> _______________________________________________
DH> Jython-users mailing list
DH> Jyt...@li...
DH> https://lists.sourceforge.net/lists/listinfo/jython-users
--
Best regards,
Ivan
mailto:pil...@ya...
http://pillesoft.freeweb.hu
|