Procedure for Calling C++ Validation Methods

The procedure to invoke a C++ validation method is as follows:

  1. Create an instance of an input stream or message buffer object from which the XML message to be validated will be read.

  2. Create an instance of the generated global element control class.

  3. Invoke the control class validation method.

  4. Validation success is indicated by a zero return status code.

  5. If validation failed, the message buffer or stream printErrorInfo method can be invoked to print the reason for the validation failure.

A program fragment that could be used to validate an employee record is as follows:

   #include "employee.h"
   #include "rtxmlsrc/rtXmlCppMsgBuf.h"

   int main (int argc, char** argv)
      int i, stat;
      const char* filename = "message.xml";
      OSBOOL trace = TRUE, verbose = FALSE;

      // Step 1: create instance of global element type class

      PersonnelRecord value;

      // Step 2: create an input stream from which the message will be read

      OSFileInputStream in (filename);
      OSXMLDecodeBuffer decodeBuffer (in);

      // Step 3: create a control class instance to tie the data object
      // and input stream object together.

      personnelRecord_CC personnelRecord (decodeBuffer, value);

      if (verbose)
         rtxSetDiag (personnelRecord.getCtxtPtr(), 1);

      // Step 4: Validate

      stat = personnelRecord.validate();

      if (0 == stat) {
         if (trace) {
            printf ("message is valid\n");
      else {
         printf ("Validation failed\n");

      return stat;