• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Newbie XML to/froPOJO question.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 24950
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too many to mention here. Google for "xml java data binding" and you will get plenty of information.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!