Java and XML Schema help

Hello there,

I have been provided with 2 XML Schema file and told to provide my data in XML format. Now I want to know using Java how can I acheive this. I have my data in the database.Can somebody please guide me to the right path and hence acheive my goal. I have attached one of the XML schema file.

cheers
Zulf
Order.xsd
zolfAsked:
Who is Participating?
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.

dpearsonCommented:
Usually the way people approach this is to use a tool, like JAXB to build a set of Java classes.

Then you read the data from the database, build up a set of objects (using the generated Java classes) and then you "marshall" (convert) those objects into the target XML.

If you use this sort of approach, you don't need to write the Java classes by hand yourself or write the code to generate the XML - the tool does it all for you.

That being said, if you've never used a tool like this, you need to learn first how to use it.
Fortunately there is a tutorial here:
https://docs.oracle.com/javase/tutorial/jaxb/intro/examples.html

I would suggest going through that whole tutorial first- download and run the examples etc. so you fully grasp what is going on.  Then you can try with your XSD files and follow the same steps.

I'm afraid I can't personally help you with doing that as I've never actually had the pleasure of having to dump out XML like this - but there's plenty of other experts who have - in case you get stuck.

Hope that helps,

Doug
zolfAuthor Commented:
dpearson,

Thanks for your feedback. That was helpful. I tried using the jxc tool to generate the java class from the xsd schema file. BUt for some reason I get this error. Could it be that java cannot convert complex xsd files. Any suggestion??

parsing a schema...
undefined simple type 'NCString '
  line 14 of file:/C:/dev/workspace/ZDemo2D/resource/Order.xsd

undefined simple type 'NCString '
  line 15 of file:/C:/dev/workspace/ZDemo2D/resource/Order.xsd

Failed to parse a schema.
dpearsonCommented:
Hmm - as I say I'm not really familiar with JAXB itself and its errors.  That sounds like a base type is just missing.

If it was me, I'd try editing down the XSD until you get a simple version that works and then try adding things back in to determine where it breaks.

Sorry I can't be more help,

Doug

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
zolfAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for zolf's comment #a41546068

for the following reason:

thanks!!
zolfAuthor Commented:
cheers!!
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
Java

From novice to tech pro — start learning today.