Obtaining information on schema locations

When parsing a document containing schema references, the caller generates and loads an OSR. In order to make sure that the appropriate OSR is loaded, the caller must determine which schemas are referenced in the document and their locations. To this end, the caller can query the XML document for namespaces and schema locations.

The caller can obtain information on the schema location by initializing the PIMA with the GXLHXEC_FEAT_SCHEMA_DISCOVERY feature. This will cause the z/OS XML parser to pause after parsing the start tag of the root element. The output buffer is then populated with records as if a normal parse was performed, with the following additional records: GXLHXEC_TOK_ROOT_ELEMENT and GXLHXEC_TOK_SCHEMA_LOCATION. GXLHXEC_TOK_ROOT_ELEMENT contains the root element name and GXLHXEC_TOK_SCHEMA_LOCATION contains the schema location information. The output buffer will not contain any start element, attribute value, or namespace declaration records. After the end of the start tag has been reached and all schema info records have been outputted, the z/OS XML parser provides the caller an opportunity to load an OSR before the parse is continued. If the parse is continued, whichever OSR was loaded by a GXLHXEC_CTL_LOAD_OSR operation will be used to validate the document. If no OSR loading operation has been performed since parser initialization, the parser must be reset in order to parse again.

The following is an example sequence, with the GXLHXEC_FEAT_SCHEMA_DISCOVERY enabled:
gxlpLoad
gxlpInit (with GXLHXEC_FEAT_SCHEMA_DISCOVERY enabled)
gxlpParse
gxlpControl(GXLHXEC_CTL_LOAD_OSR)
gxlpParse
gxlpTerminate
If the document does not contain either a schemaLocation or noNamespaceSchemaLocation attribute, then GXLHXEC_TOK_SCHEMA_LOCATION records will not appear in the output stream .

See gxlpInit — initialize the z/OS XML parser and GXL1INI (GXL4INI) — initialize a parse instance for more information on using this feature.