Generating and compiling the Java Beans for the XML Schema

This section provides the step-by-step instructions on how you can generate and compile Java Beans for an XML Schema. The first section describes the steps from within the WebSphere Studio Workbench. The second section describes the steps using a command line.

In both sections, we will use the plugins\xsdeditor\samples\PurchaseOrder\PurchaseOrder.xsd as the example.


Using the WebSphere Studio Workbench

Note: In this alpha, the Workbench only supports Java code compilation. You cannot execute a main program using the Workbench Java IDE. Therefore, to complete an application, you will need to use a command line interface. However, you might still want to follow through the steps here to learn about how you can use the Workbench Java IDE.

Steps:


 
 


Using a command line

To use a command line utility, the most important thing is to set up your classpath so that it includes all the necessary .jar files. A number of .bat file is created for your convenience:

Generating Java Beans

The plugins\xmlschemamodel\xsd2Java.bat is provided for your convenience. Take a look at this file. It uses another file under plugins\xmlschemamodel\runtime\setjavatest.bat to set up the classpath.

To make sure all the jars that are needed for generating the Java Beans are included, you need to set the environment variable VABASE to point to where you have installed the Workbench. For example:

    set VABASE=f:\vabase\itp

Once you have this setup, you can run xsd2Java.bat to generate the Java Beans. For example, type:

    xsd2Java -xsd PurchaseOrder.xsd -root PurchaseOrderType -dir f:\project
to generate the Java Beans into f:\project directory

Compiling and running the generated code

Once you have generated your Java Beans, you might want to write a client program to test out your Java Beans. An example of a client program is provided in plugins\xsdeditor\samples\PurchaseOrder\PurchaseOrderSample.java

There is also a setpath.bat file in the same directory to help you set up your classpath. To compile and run the Java Beans, you need to include the xerces.jar and the xsdbeans.jar in your classpath.