JavaTM Architecture for XML Binding
Using SchemaGen with Ant

Specification Version: 2.0
Reference Implementation (RI) Version: 2.0 ea3

JAXB 2.0: Release Notes | XJC | XJCTask | SchemaGen | schemagenTask | Sample Apps | Changelog
JAXB 1.0.x: Release Notes | Changelog
JAXB RI Extensions: Runtime Properties | XJC Customizations | Develop Plugins
JAXB RI Schema Languages: W3C XML Schema | RELAX NG | DTD
JAXB Community: Homepage | Developer interest list | FAQ

The jaxb-xjc.jar file contains the SchemaGenTask.class file, which allows the schema generator to be invoked from the Ant build tool. To use SchemaGenTask, include the following statement in your build.xml file:

<taskdef name="schemagen" classname="">
    <fileset dir="path/to/jaxb/lib" includes="*.jar" />

This maps SchemaGenTask to an Ant task named schemagen. For detailed examples of using this task, refer to the build.xml files used by the java to schema sample applications.


Environment Variables

Parameter Attributes

schemagen supports most of the attributes defined by the javac task, plus the following parameter attributes.

Attribute Description Required
destdir Base directory to place the generated schema files No
classpath Works just like the nested <classpath>element No

xjc supports all the nested elements defined by the javac task, the following nested element parameters.


Control the file name of the generated schema. This element takes a mandatory namespace attribute and a mandaotry file attribute. When this element is present, the schema document generated for the specified namespace will be placed in the specified file name.

The file name is interpreted as relative to the destdir attribute. In the absence of the destdir attribute, file names are relative to the project base directory. This element can be specified multiple times.


A path-like structure that represents the classpath. If your Java sources/classes depend on other libraries, they need to be available in the classpath.


Generate schema files from source files in the src dir and place them in the build/schemas directory.

<schemagen srcdir="src" destdir="build/schemas">

Compile a portion of the source tree.

<schemagen destdir="build/schemas">
<src path="src" />
<exclude name=""/>

$Revision: 1.3 $
$Date: 2005/12/01 22:05:59 $