XML C Pull-Parser Based Decode Functions

XML C pull-parser based decode functions handle the decoding of simple XSD types. Calls to these functions are assembled in the C source code generated by the XBinder compiler to decode complex XML schema-based messages. In general, these complement the encoding model in which individual functions exist for each type. This differs from the SAX-based functions described below which use a different model.

As an example, the code documented above to encode a simple boolean value can be reversed to decode the value:

   OSCTXT ctxt;
   int stat;
   const char* filename = "message.xml";
   OSBOOL value;

   /* Init context structure */

   stat = rtXmlInitContext (&ctxt);
   if (0 != stat) {
      printf ("Context initialization failed.\n");
      rtxErrPrint (&ctxt);
      return stat;
   }

   /* Create input source object */

   stat = rtxStreamFileCreateReader (&ctxt, filename);
   if (0 != stat) {
      printf ("Unable to open file input stream.\n");
      rtxErrPrint (&ctxt);
      return stat;
   }

   /* Match expected start tag */

   stat = rtXmlpMatchStartTag (&ctxt, OSUTF8("boolValue"), -1);
   if (0 != stat) {
      printf ("parse initial tag failed\n");
      rtxErrPrint (&ctxt);
      return stat;
   }

   /* Decode boolean value */

   stat = rtXmlpDecBool (&ctxt, &value);
   if (0 != stat) {
      printf ("decode boolean failed\n");
      rtxErrPrint (&ctxt);
      return stat;
   }

   /* Match expected end tag */
  
   stat = rtXmlpMatchEndTag (&ctxt, 0);
   if (0 != stat) { 
      printf ("parse initial tag failed\n");
      rtxErrPrint (&ctxt);
      return stat;
   }

   rtxStreamClose (&ctxt);
   rtxFreeContext (&ctxt);