File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML to Object(s) 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 "XML to Object(s)" Watch "XML to Object(s)" New topic
Author

XML to Object(s)

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 370
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

Joined: Mar 22, 2000
Posts: 12678
    
    5
You should take a look at Sun's updated JAXB toolkit.
Bill


Java Resources at www.wbrogden.com
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
The Using JAXB: Basic Examples of the The Java Web Services Tutorial should answer all of your questions.


"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 370
So can I assume that, concerning what I want to do, JAXB is a better choice than Castor ?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
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

Joined: Apr 11, 2003
Posts: 4
You can use XMLBeans, is very nice to use, but I�m having problems with multiple version of the XSD/XML.

[]�s
Mike Moreira
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML to Object(s)
 
Similar Threads
XML and Object already defined. JAXB type questions
which pattern to use??
Specify namespaces in mapping file
XML to Java object using JAXB
Facade design pattern in web services