[XOM-interest] How to make the object of nu.xom.Document may toserialize ?
Tatu Saloranta
cowtowncoder at yahoo.com
Sun Dec 9 20:40:37 EST 2007
--- Steve Loughran <steve.loughran at gmail.com> wrote:
> On Dec 5, 2007 11:39 AM, Michael Kay
> <mike at saxonica.com> wrote:
...
> > But the best way to serialize a tree
> representation of an XML document is as
> > XML. So Java serialization really isn't
> appropriate.
>
> Putting aside technical and idelogical purity,
> sometimes its good to
> serialize document trees, as that way you can
> marshall it over RMI
> with ease
>
> (a) use JDom; this is a supported use case
>
> (b) subclass nu.xom.Document, implement
> serialize/deserialize code
> that saves the doc to a UTF8 encoding in a byte
> array, and sends that
> over the wire, converting it at the far end .
While this is certainly possible, the question is, why
bother? Serialization to textual xml can be done in
couple of lines of code and results in a byte array
(directly or via ByteArrayOutputStream) easily
transmittable using normal methods, be that sending
via sockets, or even sending over RMI as a byte array.
This method is unlikely to be slower end-to-end than
object-serialization alternatives, given how fast xml
parsing and serialization is, and the overhead of
default Java object serialization.
-+ Tatu +-
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
More information about the XOM-interest
mailing list