Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate JAXB classes from just XML

Tags:

java

xml

jaxb

I need to generate classes from xml that doesn't provide a schema. I understand this is near useless, but the fact is we have xml, it's structured, and we should be able to create a model from the xml. In the past I've done it by hand, but the current xml documents I am working with are quite large and my time would probably be better spent building something that does what I need. But, I am guessing it has already been done, and I just can't find it.

Any pointers?

like image 891
DanInDC Avatar asked Feb 14 '11 17:02

DanInDC


People also ask

How do you create a Java class from an XML schema?

In the active editor tab, open the desired Schema . xsd file or an XML document, which contains the desired Schema. In the main menu, go to Tools | XML Actions | Generate Java Code From XML Schema Using JAXB.


1 Answers

There are many tools available (a quick google search should fetch you some) that can generate XSD from XML assuming string type for almost everything. You should be able to use that XSD to run JAXB to get classes.

Here's an online tool that lets you do that.

And here is a screen cap: enter image description here

like image 176
Bala R Avatar answered Sep 28 '22 00:09

Bala R