How to populate Java objects from XML given the xsd schema?

Given that I've already know a very complicated XML schema in xsd (such as How can I create the appropriate Java classes to represent the data which I convert from XML files following that xsd?

What tools and techniques may I use to fulfil that requirement?

Should I create the Java classes to represent the data manually or is it possible to use some tool to generate those Java classes?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you're running with Java 6+ you can use xjc which is installed by default.
From this you can create a JAXB object model using the XSD.

Type xjc -help to see all the possible options.
condor888Author Commented:
That is a very helpful comments.

I saw different ways to parse XML using Java, such as JAXB, JAXP, DOM and SAX API. Would you please help me to compare those?
"Parsing" and "Binding" are two different things.

JAXP (Java API for XML Processing) This is the set of XML API's in Java used to parse an XML document using things like DOM and SAX.

JAXB (Java Architecture for XML Binding) is an API used to bind XML documents to a java object model.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

condor888Author Commented:
@gurpsbassi thanks for your answer.
So when is the best scenario to use XML binding instead of just parsing it?

How can I persist the java object that we unmarshal from XML using relational database?
use XML binding instead of just parsing it
This is not a good question.

They are two different things trying to achieve two different results.
If you want to simply parse your XML, visit each of the nodes e.t.c. then JAXP for parsing.

If you want to create an object model then JAXB. Which takes a XSD and creates a model from it.

After you have got a JAXB object you can do what you want with it. All depends on what persistence framework you have in place. Simply pick the attributes of the object you want to persist and map them to column names either using a framework or classic JDBC.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
condor888Author Commented:
Sorry about the confusion and thanks again for your patience.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.