background image

JAXB Schema Generator Option

<< XJC Binding Compiler | Schema-Derived JAXB Classes >>
<< XJC Binding Compiler | Schema-Derived JAXB Classes >>

JAXB Schema Generator Option

-help
Display a brief summary of the compiler switches.
-version
Display the compiler version information.
-Xlocator
Enable source location support for generated code.
-Xsync-methods
Generate accessor methods with the synchronized keyword.
-mark-generated
Mark the generated code with the -@javax.annotation.Generated
annotation.
JAXB Schema Generator Option
The JAXB Schema Generator, schemagen, creates a schema file for each namespace referenced
in your Java classes. The schema generator can be launched using the appropriate schemagen
shell script in the bin directory for your platform. The schema generator processes Java source
files only. If your Java sources reference other classes, those sources must be accessible from
your system CLASSPATH environment variable, otherwise errors will occur when the schema
is generated. There is no way to control the name of the generated schema files.
You can display quick usage instructions by invoking the scripts without any options, or with
the -help option. The syntax is as follows:
schemagen [-d
path] [java-source-files]
The -d path option specifies the location of the processor- and javac-generated class files.
About the Schema-to-Java Bindings
When you run the JAXB binding compiler against the po.xsd XML schema used in the basic
examples (Unmarshal Read, Modify Marshal, Unmarshal Validate), the JAXB binding compiler
generates a Java package named primer.po containing 11 classes, making a total of 12 classes in
each of the basic examples, as described in
Table 17­12
.
TABLE 17­12
Schema-Derived JAXB Classes in the Basic Examples
Class
Description
primer/po/Comment.java
Public interface extending javax.xml.bind.Element;
binds to the global schema element named comment.
Note that JAXB generates element interfaces for all global
element declarations.
primer/po/Items.java
Public interface that binds to the schema complexType
named Items.
JAXB Examples
Chapter 17 · Binding between XML Schema and Java Classes
505