Using the Source Code Generator from a Java command line
Documentation Author(s): Keith Visco Arnaud Blandin
First steps Source Generator - command line options Specifying the input source Other command Line Options
Collection Types
First steps
Example: |
java org.exolab.castor.builder.SourceGeneratorMain -i foo-schema.xsd \
-package com.xyz
|
|
This will generate a set of source files from the the XML Schema
foo-schema.xsd and place them in the package
com.xyz.
To compile the generated classes, simply run javac or your favorite
compiler:
Created class will have marshal and unmarshal methods which are used to
go back and forth between XML and an Object instance.
Source Generator - command line options
The source code generator has a number of different options which may
be set. Some of these are done using the command line and others are
done using a properties file located by default at
"org/exolab/castor/builder/castorbuilder.properties".
Specifying the input source
There's more than one way of specifying the input for the Castor code
generator. At least one input source must be specified.
i |
filename |
The input XML Schema file |
- |
is |
URL |
URL of an XML Schema |
1.2 and newer |
|
Other command Line Options
package |
package-name |
The package for the generated source |
Optional |
dest |
path |
The destination directory in which to create the generated source
|
Optional |
line-separator |
unix | mac | win |
Sets the line separator style for the desired platform. This is
useful if you are generating source on one platform, but will
be compiling/modifying on another platform.
|
Optional |
types |
type-factory |
Sets which type factory to use. This is useful if you want JDK
1.2 collections instead of JDK 1.1 or if you want to pass in your
own FieldInfoFactory (see Collection
types).
|
Optional |
h |
|
Shows the help/usage information. |
Optional |
f |
|
Forces the source generator to suppress all non-fatal errors,
such as overwriting pre-existing files. |
Optional |
nodesc |
|
Do not generate the class descriptors |
Optional |
nomarshall |
|
Do not generate the marshaling framework methods (marshal,
unmarshal, validate) |
Optional |
testable |
|
Generate the extra methods used by the CTF (Castor Testing
Framework)
|
Optional |
sax1 |
|
Generate marshaling methods that use the SAX1 framework
(default is false).
|
Optional |
binding-file |
The binding file name. |
Configures the use of a Binding File to allow finely-grained
control of the generated classes
|
Optional |
generateImportedSchemas |
|
Generates sources for imported XML Schemas in addition to the
schema provided on the command line (default is false).
|
Optional |
case-insensitive |
|
The generated classes will use a case insensitive method for
looking up enumerated type values.
|
Optional |
verbose |
|
Enables extra diagnostic output from the source generator |
Optional |
nameConflictStrategy |
Name conflict strategy. |
Sets the name conflict strategy to use during XML code generation |
Optional |
fail |
|
Instructs the source generator to fail on the first error. When
you are trying to figure out what is failing during source
generation, this option will help.
|
Optional |
|
Collection Types
The source code generator has the ability to use the following
types of collections when generating source code:
Type |
Value |
Default |
Java 1.1 |
default |
java.util.Vector |
Java 1.2 |
-type j2 |
java.util.Collection |
ODMG 3.0 |
-types odmg |
odmg.DArray |
|
You can also write your own FieldInfoFactory to handle specific
collection types. All you have to do is to pass in the fully
qualified name of that FieldInfoFactory as follows:
-types com.personal.MyCoolFactory |
|
Tip: |
For additional information about the Source Generator and its options,
you can download the Source
Generator User Document (PDF). Please note that the use of a
binding file is not dicussed in that document.
|
|
|