License     Codehaus     OpenEJB     OpenJMS     OpenORB     Tyrex     
 

Main
  Home
  About
  Features
  Download
  JavaDoc
  Maven 2 support
  DTD & Schemas
  Recent changes
  News Archive
  RSS news feed

Development/Support
  Mailing Lists
  SVN/JIRA
  Contributing
  Support
  Prof. services

Related projects
  Spring ORM support
  Spring XML factories

XML
  Using XML
  XML Mapping
  XML FAQ
  XML HOW-TOs
  Custom Handlers
  Best practice

XML Code Generator
  Introduction
  Properties
  Custom bindings
  Ant task
  Maven 2 plugin
  Command line
  Schema Support
  Example

JDO
  Introduction
  First steps
  Using JDO
  JDO Config
  Types
  JDO Mapping
  JDO FAQ
  JDO Examples
  JDO HOW-TOs
  Other Features
  JDO sample JAR

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
  Presentations
  The Examples
  3rd Party Tools
  JDO Tests
  XML Tests
  Configuration
  Tips & Tricks
  CastorWiki
 
 

About
  License
  Contributors
  Marketplace
  Status, Todo
  Changelog
  Library
  Contact
  Project Name

  



Using the Ant task for the Castor XML Code Generator

Documentation Author(s):
Keith Visco
Arnaud Blandin

API Reference: The Source Builder API


Castor source generator Ant task
    Configuration
    Example


Castor source generator Ant task

An alternative to using the command line as shown in the previous section, the Castor Source Generator Ant Task can be used to call the source generator for class generation. The only requirement is that the castor-<version>-codegen-antask.jar must be on the CLASSPATH.

Configuration

Please find below the complete list of parameters that can be set on the Castor source generator.

file The XML schema, to be used as input for the source code generator. Yes, unless a nested <fileset> element is used.
package The default package to be used during source code generation. No; if not given, all classes will be placed in the root package.
todir The destination directory to be used during source code generation. In this directory all generated Java classes will be placed. No
bindingfile A Castor source generator binding file, as detailed here. No
lineseparator Defines whether to use Unix- or Windows- or Mac-style line separators during source code generation. Possible values are: 'unix', 'win' or 'mac'. No; if not set, system property 'line.separator' is used instead.
types Defines what collection types to use (Java 1 vs. Java 2). Possible values: 'vector', 'arraylist' (aka 'j2') or 'odmg'. No; if not set, the default collection used will be Java 1 type
verbose Whether to output any logging messages as emitted by the source generator No
warnings Whether to suppress any warnings as otherwise emitted by the source generator No
nodesc If used, instructs the source generator not to generate *Descriptor classes. No
nomarshal If specified, instructs the source generator not to create (un)marshalling methods within the Java classes generated. No
caseInsensitive If used, instructs the source generator to generate code for enumerated type lookup in a case insensitive manner. No
sax1 If used, instructs the source generator to generate SAX-1 compliant code. No
generateImportedSchemas If used, instructs the source generator to generate code for imported schemas as well. No
nameConflictStrategy If used, sets the name conflict strategy to use during XML code generation; possible values are 'warnViaConsoleDialog' and 'informViaLog'. No
properties Location of file defining a set of properties to be used during source code generation. This overrides the default mechanisms of configuring the source generator through a castorbuilder.properties (that has to be placed on the CLASSPATH) No
automaticConflictStrategy If used, sets the name conflict resolution strategy used during XML code generation; possible values are 'type' and 'xpath' (default being 'xpath'). No

Example

Below is an example of how to use this task from within an Ant target definition named 'castor:gen:src':

  <target name="castor:gen:src" depends="init"
             description="Generate Java source files from XSD.">

    <taskdef name="castor-srcgen"
             classname="org.castor.anttask.CastorCodeGenTask"
             classpathref="castor.class.path" />
    <mkdir dir="generated" />
    <castor-srcgen file="src/schema/sample.xsd"
                   todir="generated-source"
                   package="org.castor.example.schema"
                   types="j2"
                   warnings="true" />
  </target>
        

 
   
  
   
 


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.