Procedure for Calling C++ Validation Methods
1. Create an instance of an input stream or message buffer object from which the XML message to be validated will be read.
5. If validation failed, the message buffer or stream printErrorInfo method can be invoked to print the reason for the validation failure.
#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"); decodeBuffer.printErrorInfo(); } return stat; }
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |