Advanced Binding Schemas

The previous example demonstrated how easy JAXB can be to use, but in turn it hid all the details of the binding scheme. To become proficient in using JAXB, you must understand how binding schemes work and what default values are used when you do not specify them explicitly.

The sample binding scheme used previously in the chapter is as follows:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xml-java-binding-schema version="1.0ea">
    <element name="books" type="class" root="true" />
</xml-java-binding-schema>

It defines a single element, <books>, as the root element. The JAXB code generator then looks at the DTD:

 <!ELEMENT books (book*) > <!ELEMENT book (title, author, price) > <!ATTLIST book category CDATA #REQUIRED ...

Get Java™ Web Services Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.