File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Newbie XML to/froPOJO question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Newbie XML to/froPOJO question." Watch "Newbie XML to/froPOJO question." New topic

Newbie XML to/froPOJO question.

Jason Pepper

Joined: Oct 15, 2005
Posts: 9
Are there any convenient free libraries to do the XML <-> POJO translation.
I know of JAXB (but I need to have an XSD to generate a POJO or do I?)

I need something that does the XML <-> POJO without any additional steps.
No xsd, dtd. It should just work!

Ideally, the XML <-> POJO translation should be idempotent so that I can
use XPath on the XML and the same XPath on the POJO (using Apache JXPath)
to get to a node.

anything out there?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Too many to mention here. Google for "xml java data binding" and you will get plenty of information.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Are you expecting to generate a POJO class without a DTD or XSD? consider the following series of sample "documents".

Based on the first one, you might want getAge to have some numeric return type, but later examples confound that. The first example doesn't demonstrate the non-required sex attribute, and what about allegies? It's only when you get to the third example that you see Person has a list of allegies. This makes me thing that if you wanted to generate a useful POJO from XML documents you would need to supply several example and then use some sort of fancy neural net algorithms to discover the underlying POJO type. Or bite the bullet and work from an XML Schema

There is no emoticon for what I am feeling!
I agree. Here's the link:
subject: Newbie XML to/froPOJO question.
It's not a secret anymore!