Hi James,
James Cowan wrote:
> Hi
>
> I am a bit unclear on how to get the velocity template source code
> generation working. I am using castor 1.3.
>
> I have tried org.exolab.castor.builder.SourceGenerator with the
> option -jclassPrintingType (as per manual) but get
>
> Invalid command line option -jclassPrintingType.
This is not an option on the SourceGenerator class, but a simple setter
that should be used as follows (taken from a sample test case):
SourceGenerator generator = new SourceGenerator();
String xmlSchema = getClass().getResource("test.xsd").toExternalForm();
InputSource inputSource = new InputSource(xmlSchema);
generator.setDestDir("./codegen/src/test/java");
generator.setSuppressNonFatalWarnings(true);
// uncomment to use Velocity for code generation
generator.setJClassPrinterType("velocity");
Does this address your question ?
> I then looked at the source code and tried
> org.exolab.castor.builder.SourceGeneratorMain with the option
> -classPrinter velocity
>
> I get the error Invalid command line option -classPrinter but then
> get the message -- Using JClass printing type velocity which seems to
> indicate it is using velocity but I am not sure.
Can you supply me with a short JUnit test case ? I just had a look at
the sources, and this does not make sense.
> How do tell whether it is using velocity or not. I switched on log4j
> logging to debug but it was not obvious.
If it's not, we should definitely improve logging output. But you can
definitely tell by having a look at the files generated. If you use
'standard' mode, you would still see this old
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
output all over the files.
In addition, I think we should add additional output to the Velocity
macros so that it is apparent what version of Castor has been used to
create the files (and that Velocity has been used).
> I also want to make changes main.vm. If I put a copy of main.vm in
> target\classes\org\exolab\castor\builder\printing\templates should it
> pick up this version of main.vm instead of the one embedded in the
> jar file? It does not seem to..
Not really sure. But for starters, why don't you get Castor sources from
SVN trunk, and amend the files locally, and build Castor yourself ?
> James
Werner
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email