aspose file tools*
The moose likes XML and Related Technologies and the fly likes serializing and deserializing xml/kml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "serializing and deserializing xml/kml" Watch "serializing and deserializing xml/kml" New topic
Author

serializing and deserializing xml/kml

darshan sure
Greenhorn

Joined: Aug 25, 2009
Posts: 20
Hi,

I have to save the data from the 'jtable' of my desktop application,along with other user information in to xml format (rather kml). So for this serialization I was looking for different ways to do this online.

Some of the serialization-deserialization options that I found were

Xstream java library
and
JAXB


I need some suggestions as to what is the best way in terms of efficiency to do serialization-deserialization (xml to Java objects)

And if it is JAXB , apparently xsd's is a must. So to begin with I have to right my .xsd file right? please correct me if I am wrong as this is the first time ever I am trying to do something like this.

Thanks.

Velu Kasirajah
Greenhorn

Joined: Feb 06, 2010
Posts: 15
You can also take a look at Apache XMLBeans.


Velu Kasirajah
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Your first mistake was looking for "the best way in terms of efficiency". For one thing you haven't decided what kind of "efficiency" you have in mind, and anyway efficiency should never be the first and only thing on your list of requirements. It shouldn't be first on any list.

And second, you have allowed yourself to be led astray. This "kml" format is the Google Maps KML format, isn't it? And since Google hasn't defined a schema for it, you shouldn't either. Which eliminates heavyweight tools which work from schemas.

Personally, to generate KML from Java data I would go with one of the streaming XML serializers, which are built into Java since version 6.
darshan sure
Greenhorn

Joined: Aug 25, 2009
Posts: 20
Thanks guys for responding to my post.

@Paul Clapham

I am new to this field of Java development. And my problem has been in selecting the right tool for the task at hand, any solution to this problem of mine

I had to find an efficient way to do it as there were instances in my other projects where things would work but was not fast and efficient .
Because in situation where in the xml/kml files are huge the time does matter.

Anyways thanks for clarifying about the KML schemas. I googled for KML schemas I did find some stuff. But without getting in to detail with kml.

I want to know what exactly you mean by
" streaming XML serializers, which are built into Java since version 6."
-- could you please point me to a online link for the same.


heavyweight tools which work from schemas that include JAXB, Apache XMLBeans; for what kind of applications do they fit in.
( Apache XMLBeans also needs schemas - the http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html)


Xstreams at first glace does seem like serves the purpose.


I really do appreciate all your input

Thanks a lot.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

darshan sure wrote:
I had to find an efficient way to do it as there were instances in my other projects where things would work but was not fast and efficient .
Because in situation where in the xml/kml files are huge the time does matter.

You can't talk about efficiency without having at least two options to compare. Right now you have nothing. So don't get diverted down that road until you know what you're doing.

Besides, you said your data was coming from a JTable so it can't possibly be huge.
I want to know what exactly you mean by
" streaming XML serializers, which are built into Java since version 6."
-- could you please point me to a online link for the same.

http://java.sun.com/javase/6/docs/api/javax/xml/stream/package-summary.html
darshan sure
Greenhorn

Joined: Aug 25, 2009
Posts: 20
Thanks so much Paul Clapham for the javax.xml.stream link.

I guess now have some thing to compare

The XStream and java streaming XML

So trying out these two tools.

Any suggestions here?

I appreciate your feed back!
 
Consider Paul's rocket mass heater.
 
subject: serializing and deserializing xml/kml