How to add inline xml schema using jaxb?

How can I use JAXB for XML having no schema definitions?

  • - I have some XML files that I need to parse and use them as POJO - These XML files doesn't have any schema definitions(.xsd) associated with them. They all look same though, I mean the schema can be handcoded - How can I use JAXB in this situation?

  • Answer:

    You can add JAXB annotations to existing Java objects to map them to the desired XML format.  You do need to generate a JAXB model from an XML schema.

Blaise Doughan at Quora Visit the source

Was this solution helpful to you?

Other answers

inst2xsd from xmlbeans (http://xmlbeans.apache.org) creates an xsd from xml instances. Sometimes it needs a bit of cleanup, but most of the time, the chain inst2xsd -> xjc -> jaxb works very well for me.

Hans-Peter Zorn

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.