File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Castor source-gen Help" Watch "Castor source-gen Help" New topic
Author

Castor source-gen Help

Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Hi,
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"/>
</path>

<taskdef name="castor-srcgen"
classname="org.exolab.castor.tools.ant.taskdefs.CastorSourceGenTask"
classpathref="castor.class.path" />

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

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

Like:

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

package castor;

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/

import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
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 java.io.Serializable {
etc...
....
....
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 com.igt.atg.ibe.com.igt.atg.ibe.castor.

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

thanks n regards,
raminder.singh
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: http://aspose.com/file-tools
 
subject: Castor source-gen Help
 
Similar Threads
What is the difference between two path task code?
Ant
Session not bound?
Ant: earExport is not working with Jdk 1.4
Hibernate - Confusing Configuration Errors