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!
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.
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.