XML Binding Development Guide : PART II Code Generation Examples : Chapter 4 Purchase Order Example & Namespace Qualification : Generating Code from Schema
Generating Code from Schema
To generate the output for the schema describing the Purchase Order XML document:
1. Follow the instructions in Chapter 2, “Setup,” in the HydraExpress User Guide to set up your environment.
2. Open a command prompt and navigate to the directory installdir\examples\xmlbinding\namespace.
3. Invoke the code generator as shown below:
 
rwsfgen example-project.xml
The HydraExpress project file example-project.xml provided as an argument specifies the schema po1.xsd, assigns a project name namespaceExample on which the code generation directory is based, and also includes the options to use SourcePro classes and to include whitespace when marshaling.
This invocation is the same as entering the options and files directly on the command line as follows:
 
rwsfgen -projectname namespaceExample -sourcepro -whitespace po1.xsd
NOTE >> SourcePro is not included with HydraExpress. It is a separate product from Rogue Wave Software and must be purchased additionally.
For more information on the use of HydraExpress project files in shipped examples, see “The Use of the HydraExpress Project File in Shipped Examples,” in the HydraExpress User Guide. For complete information about the command-line options, see Generator Options,” in the HydraExpress Web Service Development Guide.
NOTE >> The example program in this section uses SourcePro C++ classes. The provided po1_main.cpp file will not compile if you use the -stl binding. The -sourcepro option is specified in the HydraExpress project file example-project.xml used as an argument above. For more information on the HydraExpress project file, see “The Generated Project Directory,” in the HydraExpress Web Service Development Guide.
Generator Output
The classes and other files generated for this example are the same as for the Basic example. For a description of the generated code generation directory structure and specific generated files, see “Generated Files.”
Note the generated file po1_main.cpp in the namespaceExample\app\data directory. You can create an application main by editing this file. Replace the TODO items with your application logic. Compile your application as described in “Building and Compiling.”
This example description assumes use of the implemented version of po1_main.cpp located in the installdir\examples\xmlbinding\namespace directory. Before compiling, copy the file po1_main.cpp into the namespaceExample\app\data directory and the file po1.xml into the namespaceExample\bin directory.
NOTE >> Source code other than that in the app directory is not overwrite protected. You should never add business logic or make any other changes to the generated source code as these changes are lost the next time the code is generated.