|  |  |  | License Codehaus OpenEJB OpenJMS OpenORB Tyrex
Old releases
General
Release 1.3
Release 1.3rc1
Release 1.2
Main
Home
About
Features
Download
Dependencies
Reference guide
Publications
JavaDoc
Maven 2 support
Maven 2 archetypes
DTD & Schemas
Recent HTML changes
News Archive
RSS news feed
Project Wiki
Development/Support
Mailing Lists
SVN/JIRA
Contributing
Support
Continuous builds
Prof. services
Related projects
Spring ORM support
Spring XML factories
WS frameworks
XML
XML
XML Code Generator
XML Code Generator
JDO
Introduction
First steps
Using JDO
JDO Config
Types
JDO Mapping
JDO FAQ
JDO Examples
JDO HOW-TOs
Tips & Tricks
Other Features
JDO sample JAR
Tools
Schema generator
Advanced JDO
Caching
OQL
Trans. & Locks
Design
KeyGen
Long Trans.
Nested Attrs.
Pooling Examples
LOBs
Best practice
DDL Generator
Using DDL Generator
Properties
Ant task
Type Mapping
More
The Examples
3rd Party Tools
JDO Tests
XML Tests
Configuration
About
License
User stories
Contributors
Marketplace
Status, Todo
Changelog
Library
Contact
Project Name
## 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:
    javac com/xyz/*.java
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.
Option | Args | Description | Version
i | filename | The input XML Schema file | -
is | URL | URL of an XML Schema | 1.2 and newer
### Other command Line Options
Option | Args | Description | Optional?
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
gen-mapping |  | (Additionally) Generate a mapping file. | 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
jclassPrintingType | JClass printing mode. | Specifies the JClass printing mode to use during XML code generation; possible values are`standard` (default) and `velocity`; if no value is specified, the default mode is `standard`. | 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.
| Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners. |