File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Castor source-gen Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Castor source-gen Help" Watch "Castor source-gen Help" New topic

Castor source-gen Help

Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
I'm using sourceGen of castor:

<target name="castor" depends="init" description="Generate Java source files from XSD.">
<path id="castor.class.path">
<pathelement location="${lib}/castor-1.0.jar"/>
<pathelement location="${lib}/castor-1.0-xml.jar"/>
<pathelement location="${lib}/castor-1.0-commons.jar"/>
<pathelement location="${lib}/castor-1.0-srcgen-ant-task.jar"/>
<pathelement location="${lib}/xerces-J_1.4.0.jar"/>

<taskdef name="castor-srcgen"
classpathref="castor.class.path" />

<mkdir dir="${srcroot}/igt/atg/ibe/castor" />
<castor-srcgen file="${srcroot}/igt/atg/ibe/castor/schema1.xsd"
package="castor" warnings="false"/>

All .java files generated in ${srcroot}/igt/atg/ibe/castor package--


* This class was automatically generated with
* <a href="">Castor 1.0</a>, using an XML
* Schema.
* $Id$

package castor;

//- Imported classes and packages -/

import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;

* Class Address.
* @version $Revision$ $Date$
public class Address implements {
Problem is:
1) There are few comments before package statement (autogenerated)..thats doesn't let it compile. (whats solution to avoid it?)

2) Actual package statement should be
package com.igt.atg.ibe.castor;

but if i write this
package="com.igt.atg.ibe.castor" warnings="false" in AntTask.. it stores all *.java files in

how to get right package statement (package com.igt.atg.ibe.castor)
in generated .java files.?

thanks n regards,
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Try chainging the toDir from ${srcroot}/igt/atg/ibe to ${srcroot} and specify the package value as "com.igt.atg.ibe.castor" assuming srcroot value is "com".
I agree. Here's the link:
subject: Castor source-gen Help
jQuery in Action, 3rd edition