• Post Reply Bookmark Topic Watch Topic
  • New Topic

Castor source-gen Help

 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!