Generated C Function Format and Calling Parameters

Generated encode functions are written to a .c file with a name of the following format:

   <xsdFileName>Enc.c

where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd, encode functions for each type and global element defined in the specification will be written to xEnc.c.

The format of the name of each generated JSON type encode function is as follows:

   [<ns>]JsonEncT_<typeName>

where <typeName>is the name of the C type for which the function is being generated and <ns>is an optional namespace setting that can be used to disambiguate element names from multiple sources (note: this should not be confused with XML namespaces which are different).

The calling sequence for each encode function is as follows:

   status = <encodeFunc> (OSCTXT* pctxt, <name>[*] value);

In this definition, <encodeFunc> denotes the encode function name defined above.

The pctxt argument is used to hold a context pointer to keep track of encode parameters. This is a basic "handle" variable that is used to make the function reentrant so it can be used in an asynchronous or threaded application. The user is required to supply a pointer to a variable of this type declared somewhere in his or her program.

The value argument contains the value to be encoded or holds a pointer to the value to be encoded. This variable is of the type generated from the XSD type. The object is passed by value if it is an atomic XSD simple type such as boolean, integer, etc.. It is passed using a pointer reference if it is a structured type value (in this case, the name will be pvalue instead of value ). Check the generated function prototype in the header file to determine how this argument is to be passed for a given function.

The function result variable statreturns the status of the encode operation. Status code 0 (zero) indicates the function was successful. A negative value indicates encoding failed. Return status values are defined in the rtxErrCodes.h include file. The error text and a stack trace can be displayed using the rtxErrPrint function.