Getting Started with C or C++ Sample Programs

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:

  1. Open an MS-DOS or other command shell window.

  2. Change directory (cd) to the employee sample directory:

       cd c/sample/Employee

    Note: this assumes the starting point is the XBinder installation root directory.

  3. Execute the nmake (Windows) or make (Linux/UNIX) utility program to build the program:


    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.

  4. 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.

  5. Invoke writer from the command line:


  6. 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.

  7. Invoke reader from the command line:


  8. 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.