Steps for parsing XML documents with validation

About this task

The following steps summarize the process of parsing XML documents using the z/OS XML parser with validation:

Procedure

  1. Call the parser load service or run the XML CICS® PLT program if in the CICS environment. This will load the parser into storage. For more information, see Loading the validating parser code.
  2. Call the OSR initialization utility. This establishes the OSR generator Instance Memory Area (OIMA), which is then used as the work area for the OSR generator.

  3. Call the OSR generator utility. This utility creates an OSR from one or more text-based schemas passed to the OSR generator instance, using the load schema utility.
    Note: An OSR can be saved and then used for parsing future documents that share the same schema(s) from which the OSR was generated. As a result, steps 2 and 3 may not be required each time an XML document is parsed using validation.
  4. Call the parser initialization service. This establishes the PIMA, which is then used to create and store the initial data structures required to begin the parse process.
  5. Call the control service. This will load the generated OSR into the z/OS XML parser.

  6. Call the parse service to parse the document.
    Note: During the parse process and before the end of the document is reached, if the input buffer is empty or the output buffer is full, a warning is issued and the parse service is stopped. Otherwise, the parse service will continue until the document is fully processed.
  7. The application processes the output buffer.
  8. Determine if additional schemas need to be processed. If so, repeat steps 3, 5 and 6. If you want to reuse an existing OSR, use the OSR load utility.

  9. Determine if there are additional documents to be processed. If so, call the termination service to terminate the existing parse process, and repeat steps 1 -7.

    Tip: For increased performance, the caller can use the control service in place of the termination and initialization services. The control service enables the PIMA to be reused, avoiding the need to free resources and re-initiate a new PIMA. However, the PIMA can only be reused in this way when the XML documents are in the same encoding. See gxlpControl — perform a parser control function and GXL1CTL (GXL4CTL) — perform a parser control function for more information on the control service.