Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML to Object(s)

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
given an XML file, its schema, how can I obtain an Java Object(s) representation mapping to the XML ?

1. I googled and found "Castor" is one. Any other tool can be used to convert XML file with schema into Java Objects ?

2. What do I need to 'prepare' if I use Castor to generate the Java Object(s) for me ? I assume that besides the XML file, I need the java class format, and some kind of mapping file showing the relation between class instance variables and XML elements/attributes, is that right ? anything else ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should take a look at Sun's updated JAXB toolkit.
Bill
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Using JAXB: Basic Examples of the The Java Web Services Tutorial should answer all of your questions.
 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So can I assume that, concerning what I want to do, JAXB is a better choice than Castor ?
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Castor is in independent project that predates JAXB. I haven't used it, so I can't say how good it is. By all accounts it looks like JAXB will be becoming part of Java or Java Enterprise Edition.
 
Mike Moreira
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use XMLBeans, is very nice to use, but I�m having problems with multiple version of the XSD/XML.

[]�s
Mike Moreira
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic