• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Castor source-gen Help

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic