To begin using XBinder to generate C source code, one should start with the sample programs. These are located in the c/sample or cpp/sample subdirectories of the installation. A good sample program to get started with is the Employee sample program. This program contains an XML schema file that describes an employee personnel record.
To run this sample program from the command-line interface, the following procedure should be followed:
Open an MS-DOS or other command shell window.
Change directory (cd) to the employee sample directory:
cd c/sample/Employee
Note: this assumes the starting point is the XBinder installation root directory.
Execute the nmake
(Windows) or make
(Linux/UNIX)
utility program to build the program:
nmake
Note: nmake is a make utility program that comes with the Microsoft Visual C++ compiler. It may be necessary to execute the batch file vcvars32.bat that comes with Visual C++ in order to set up the environment variables to use this utility.
This should cause the XBinder compiler to be invoked to compile the employee.xsd XML schema file. It will then invoke the configured C compiler to compile the generated C file and test drivers. The result should be a writer.exe and reader.exe program file which, when invoked, will encode and decode a sample employee record.
Invoke writer from the command line:
writer
This will generate an encoded record and write it to a disk file. By default, the file generated is message.xml. The test program has a number of command line switches that provide encoding options. To view the switches, enter writer ? and a usage display will be shown.
Invoke reader from the command line:
reader
This will read the disk file that was just created by the writer program and decode its contents. The resulting decoded data will be written to standard output. The test program has a number of command line switches that provide decoding options. To view the switches, enter reader ? and a usage display will be shown.
The procedure to run a C++ sample program is the same except that you would start in one of the cpp/ sample directories. The same procedure applies: execute the make utility and then run the writer and reader programs.