Generated Print Functions

The -print option causes print functions to be generated. These functions can be used to print the contents of variables of generated types.

The generated print functions are written to a .c file with a name of the following format:


where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd and -print is specified, print functions will be written to xPrint.c . If the file being processed is a WSDL file, the suffix would be WSDLPrint.c (for example, x.wsdl would produce xWSDLPrint.c ).

The format of the name of each generated print function is as follows:


where <typeName>is the name of the XSD type for which the function is being generated and <ns>is an optional namespace setting that can be used to disambiguate names from multiple sources (note: this should not be confused with XML namespaces which are different). Note that print routines are generated for each type within a specification making it possible to print the contents of any typed variable (some generated functions are only generated for global elements).

The calling sequence for each generated print function is as follows:

    <printFunc> (const char* name, <typeName>* pvalue)

In this definition, <printFunc> denotes the formatted function name defined above.

The name argument is used to hold the top-level name of the variable being printed. It is typically set to the same name as the pvalue argument in quotes (for example, to print an employee record, a call to 'Print_PersonnelRecord ("employee", &employee) might be used).

The pvalue argument is used to pass a pointer to a variable of the item to be printed.

The code snippet in the section entitled Procedure for Calling C Decode Functions contains an example of calling a generated print function. If a successful status is returned from calling the decode function, the contents of the decoded variable are printed:

    stat = XmlD_personnelRecord (&ctxt, &employee);
    if (stat == 0) {
       if (trace) {
          printf ("Decode of PersonnelRecord was successful\n");
          printf ("Decoded record:\n");
Print_PersonnelRecord ("employee",