|  |  |  | 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

Documentation Author(s):
Keith Visco
Arnaud Blandin

API Reference: The Source Builder API

News
Source generation & Java 5.0
Introduction
Invoking the XML code generator
XML Schema

## News

### Source generation & Java 5.0

Since release 1.0.2, the Castor source generator supports the generation of Java 5.0 compliant code. The generated code -- with the new feature enabled -- will make use of the following Java 5.0-specific artifacts:

- | Use of parameterized collections, e.g. `ArrayList<String>`.
- | Use of `@Override` annotations with the generated methods that require it.
- | Use of `@SuppressWarnings` with "unused" method parameters on the generated methods that needed it.
- | Added "enum" to the list of reserved keywords.

To enable this feature (off by default), please add or uncomment the following property in your custom `castorbuilder.properties` file:

    # Specifies whether the sources generated should be source compatible with
    # Java 1.4 or Java 5.  Legal values are "1.4" and "5.0".  When "5.0" is
    # selected, generated source will use Java 5 features such as generics and
    # annotations.
    # Defaults to "1.4".
    #
    org.exolab.castor.builder.javaVersion=5.0

## Introduction

Castor's Source Code Generator creates a set of Java classes which represent an object model for an XML Schema (W3C XML Schema 1.0 Second Edition, Recommendation)1, as well as the necessary Class Descriptors used by the marshaling framework to obtain information about the generated classes.

Note

The generated source files will need to be compiled. A later release may add an Ant taskdef to handle this automatically.

## Invoking the XML code generator

The XML code generator can be invoked in many ways, including by command line, via an Ant task and via Maven. Please follow the below links for detailed instructions on each invocation mode.

- | Command line interface
- | Ant task for Castor code generation
- | Maven 2 plugin for Castor code generation

## XML Schema

The input file for the source code generator is an XML Schema2. The currently supported version is the W3C XML Schema 1.0, Second Edition Recommendation1. For more information about XML Schema Support, check the XML Schema page

1Castor supports the XML Schema 1.0 Second Edition Recommendation

2XML Schema is a W3C Recommendation

3XPath is a W3C Recommendation

<notice> Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. </notice>
<notice> 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. </notice>