Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

XML to Object(s)

 
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 ?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should take a look at Sun's updated JAXB toolkit.
Bill
 
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.
 
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
 
Your mother is a hamster and your father smells of tiny ads!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic