Does JAXB Always Require XSD

http://www.oracle.com/technetwork/articles/javase/index-140168.html#binsch - 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

http://jaxb.java.net/tutorial/section_1_3-Hello-World.html#Hello%20World -

And here is a Hello World example without using xsd.

http://www.mkyong.com/java/jaxb-hello-world-example/

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

+3


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 ( http://www.oracle.com/technetwork/articles/javase/index-140168.html#binsch ) 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.

+4


source


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.



0


source


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.

0


source







All Articles