Reputation: 3271
I have a requirement to create java model classes (binding classes) from XML files. Unfortunately I don't have XSD schema. There are many already existing XML's.
Strangely , Castor or JAXB both use XSD schema to generate binding model classes. What if you don't have a schema? Not all XML are created using Schema!
Upvotes: 2
Views: 3174
Reputation: 149057
The reason that XML binding technologies do not generate Java classes from XML is that it is an extra level of complexity:
You have a couple of options. The first is you can use a tool to generate an XML schema from the XML and then generate the classes from that. Or you could annotate your existing classes to map them to XML:
Upvotes: 2
Reputation: 12506
You could use a schema inference tool like Trang. It can produce xsd
from xml
. You could then tweak the generated schema or just feed it straight to JAXB/Castor etc.
Upvotes: 3