JaxMe is an open source implementation of the Java API for XML Binding (JAX-B). Running JaxMe schema generator (Sun calls the equivalent piece of software in its own JAX-B implementation the schema compiler) is normally part of your build process and there's is a sample ANT task on the website. If you happen to build your project with Maven, there is a maven-plugin, too.
But just without ANT or Maven, running JaxMe from the command line needs the following:
- Unpack the JaxMe distribution into a directory (here:
d:\prg\jaxme-051
) - Write yourself a shell script like this one:
set JAXMELIB=D:\prg\jaxme-051\lib java -cp %JAXMELIB%\jaxme2-0.5.1.jar;%JAXMELIB%\jaxmeapi-0.5.1.jar;%JAXMELIB%\jaxmejs-0.5.1.jar;%JAXMELIB%\jaxmexs-0.5.1.jar org.apache.ws.jaxme.generator.Main %*
- Save this as xjc.cmd (that's what Sun called their stuff)
- Running xjc should give you the JaxMe command line options, like:
A Schema file must be specified Usage: org.apache.ws.jaxme.generator.Main <inputfile> [options] Reads a schema definition from the given <inputfile> Possible options are: --bindingFile=<filename> Adds an external binding file. Multiple external binding files may be used by repeating this option. --force Force overwriting files --schemaReader=<class> Sets the SchemaReader class; defaults to org.apache.ws.jaxme.generator.sg.impl.JAXBSchemaReader --sgFactoryChain=<class> Adds an instance of
to the generation process. --logFile=<filename> Sets a logfile for debugging purposes. By default System.err is used. --logLevel=<level> Sets the default logging level. Possible levels are fatal, error (default), warn, info and debug --option=<name=value> Sets the option to the given . --package=<name> Sets the package of the generated sources to . --resourceTarget=<dir> Sets the directory where to generate resource files. By default, the same directory is used for Java sources and resource files. --target=<dir> Sets the directory where to generate Java sources. By default the current directory is used. --validating Turns the XML parsers validation on. - Write another shell script for transforming a schema (I do this because I hate to loose a hard-fought-for command line to an accidental
exit
in the wrong shell. Additionally I can't always remember all them incantations when I need to run the same stuff days later.) You need to specify the schema, the target package and the target directory, in which the package will be created (this would be some path pointing into your project). Like so:
xjc --target d:\src\Verifications\src\jaxme --package de.inpc.[something].vo D:\src\Verifications\src\jaxme\[something].xsd
Call it compile-[something].cmd - Running the compile-[something] shell script should generate lots of logging and output java classes generated from the schema in your target directory.
- These are java sources, before using them you need to compile them.
That's all it takes – happy JaxMe-ing!
Keine Kommentare:
Kommentar veröffentlichen