Does JAXB Always Require XSD - This article says "JAXB requires that the XML document you want to access has a schema."

Here is a Hello World example, uses hello.xsd -

And here is a Hello World example without using xsd.

The spec states that JAXB also works without xsd, if that's true how far off is the term "binding". I believe the binding happens by schema binding.

Ordering will be helpful. Thanks to


source to share

3 answers

JAXB 2 (JSR-222) implementations do not require XML Schema. You can start with the object model. You only need to add annotations where you want to override the default display behavior.

Note. The link you provided ( ) was for JAXB 1 (JSR-31) which requires XML Schema. JAXB 2, which is what most people talk about when they say JAXB does not require XML Schema.



the Customer class in the tutorial is nothing more than a binding object that will be generated from XSD using JAXB. The guy avoided this in his tutorial.



xsd is just a formal xml representation, similar to "Class" for "Object". You can have compatible xml without xsd (in this case xsd is hidden). While it is true that we start with xsd and generate Java objects for the most part, you can do the opposite. "schemagen" actually allows you to come up with an xsd for a given java class. It's easy to say that there are several starting points.



All Articles