Hi James, James Cowan wrote: > Hi Werner > > I am running the schema compiler from maven or ant. > > I could not get the maven plugin to pass in the flags jclassPrintingType > or classPrinter. Looking at the code there is no option in the plugin. > > However the ant task below does work and I got all the velocity stuff > working - the problem was that I had not set up the path to > src/main/resources in ant. > > When I made a mistake in the velocity script I got an error and a > velocity.log file! > > It would be good to get the classPrinter flag into the maven plugin - > happy to give a hand if you want. Can you please create a new Jira issue at
http://jira.codehaus.org/browse/MCASTOR and I will take care of it ? > What I am actually doing is put JPA annotations (@ID, @Entity, @Column > etc) into xsd annotations; it all works but it would be nice if I could > put this information into appinfo subelement of annotation; this would > feel a bit neater. Is it possible to get access the appinfo sub element > via the model passed to through the veclotiy context? Currently I am > just extracting e.g @Entity from $jClass.getJDocComment() with crude > assumption that the annotations are at the end of the comment. Nice idea. But can I talk to you off-line about this, as there's something I'd like you to know about: the XML schema extensions for the XML code generator. > > James > > <java > classname="org.exolab.castor.builder.SourceGenerator" > classpath="${p_classpath_resources};${p_classpath}" fork="true"> > <arg value="-i"/> > <arg value="${p_schema}"/> > <arg value="-f"/> > <arg value="-verbose"/> > <arg value="-types"/> > <arg value="arraylist"/> > <arg value="-package"/> > <arg value="${p_package}"/> > <arg value="-dest"/> > <arg value="${p_dest_dir}"/> > <arg value="${p_nodesc}"/> > <arg value="${p_nomarshall}"/> > <!-- > <arg value="-jclassPrintingType"/> > --> > <arg value="-classPrinter"/> > <arg value="velocity"/> > </java> Btw, you really should not be using this old Ant task definition anymore. > > > ----- Original Message ----- From: "Werner Guttmann" <[email protected]> > To: <[email protected]> > Sent: Wednesday, August 26, 2009 10:25 PM > Subject: Re: [castor-user] velocity templates > > >> 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 >> >> > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

