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 XML Schema to Java object 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 Schema to Java object" Watch "XML Schema to Java object" New topic

XML Schema to Java object

Ashish Sarin
Ranch Hand

Joined: Nov 20, 2000
Posts: 432
Hello guys

I was trying to do something like this:
Read an XML Schema file and creat a Java object. The generated Java object contains information on which element types exist in the Schema, their possible attributes, the sub-elements it can contain, the attributes which are optional, the attributes which are required, etc etc. I mean this Java object will be the single point of contact for me to know everything about XML Schema.

Anyone can suggest me or provide some sample code to how to accomplish this kind of requirement ??

Looking forward to receive replies from you guys.

ashish sarin

Author of
Getting started with Spring Framework
Portlets in Action
Spring Roo 1.1 Cookbook
Portlets blogSpring Roo blog
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Well i'm just a green horn about this stuff, but i think the RELAXNG tool will generate JAVA classes!

Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
JAXB was designed specifically to do this -- check out the Web Services Developer Kit on the Java website.

Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
One more

Spritle Software Blogs
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Does anyone know which of these tools, JAXP, Castor or other, are currently being used the most to generate Schema's or build Schema's from scratch these days?

I've just been reading artilces on '' where the W3C XML Schema approach is being compared to the RELAX NG approach and it sounds like the RNG approach is more flexible and easier to develop, does anyone have any thoughts or experience with these tools?

What i'm really hoping to find is a tool that will help me build a 'detailed' Schema and by that i mean a tool that will ask which field i want to 'enumerate' and then go ahead and insert the 'enumerations' in the Schema automatically!

For example, if i say i want to 'enumerate' the state field in the Schema, the tool will examine a database or XML file, determine the unique data values for the state field and insert an 'enumeration' entry for each state into the Schema!

Will JAXP or CASTOR help build a 'detailed' Schema along those lines or even a 'shell/template' Schema for that matter?

I have been able to generate a generic 'shell' Schema using Oracles XML kit and Oracle DB, but i havn't been able to verify if i will have to pay a licensing fee if i move it to production!

Thanks for any thoughts!
I agree. Here's the link:
subject: XML Schema to Java object
It's not a secret anymore!