> Hi,
>
> I noticed with .Net the framework provides a simple ability to
> serialize an object to XML and back again.
>
> Does Java have the same functionality?
Java has a standard API for extensions that do XML binding, and there's
a Sun reference implementation.
http://java.sun.com/webservices/jaxb/index.jsp
I use Castor for this, though not a standard JAXB implementation, and I
find it to be excellent and pretty efficient. Many of my applications
are built starting with an XML Schema and I use Castor to automatically
generate objects from that. Starting there, it's extremely easy to
Marshall/Unmarshall objects to and from XML, and I also do database
binding to the same objects.
The problem with having a "simple" ability to marshal or unmarshal, is
that the relationship between an object and its XML representation is
not always quite so simple.
If you don't really care about the structure of the XML and don't need
precise control over naming and type conversion, you can use XStream
very simply.
> Also, I have a system which needs to persist objects and then perform
> some custom scripting on them - I assume storing objects as binary
> would be ill advised due to version incompatibility - but XML would be
> make need for a *huge* table - although I guess I could zip and store
> them. That might be slow and a lot of overhead to extract them though.
I use Hibernate to map my objects (the same ones I map to XML Schema) to
a database. It's pretty efficient both in terms of storage size and
performance, but that's relative, of course. Since I specialize in a
certain type business software, I consider the benefits to data
integrity and the design-by-contract opportunities that come with xml
binding, to far outweigh performance considerations.
> I noticed with .Net the framework provides a simple ability to
> serialize an object to XML and back again.
>
> Does Java have the same functionality?
See the classes
java.beans.XMLEncoder,
java.beans.XMLDecoder

Signature
"TFritsch$t-online:de".replace(':','.').replace('$','@')
timasmith@hotmail.com - 25 Feb 2006 02:25 GMT
I did - so neither this nor Castor seems to do a deep copy of my
objects - is that a flag on either?
I have a hierarchy of objects which all need to be stored.