This utility generates an optimized representation of one or more XML schemas.
There are no performance implications.
|
A pointer to an OSR generator Instance Memory Area (OIMA).
A pointer to an area to receive the address of the optimized schema representation generated by this utility. See the usage notes below for important details about this parameter.
A pointer to an area where the utility stores the return code.
A pointer to an area where the utility stores the reason code. The reason code is only relevant if the return code is not XRC_SUCCESS.
All parameters in the parameter list are required.
Return Value:
The value returned by this utility is the length of the OSR buffer returned to the caller through the schema_osr_p parameter. If there is a problem during the generation of the OSR, the value returned will be zero. See the usage notes below for more information about this value and the OSR buffer returned.
Return and Reason Codes:
Register 15 will contain the return value of this utility. The return and reason code are both set as output parameters. The value of the reason code is undefined when the return code has no associated reasons. Return and reason codes are defined in the header file gxlhxr.h (see gxlhxr.h (GXLYXR) - defines the return codes and reason codes). For reason code descriptions, also see Reason codes listed by value.
#include <stdlib.h>
#include <stdio.h>
#include <gxlhosrg.h>
#include <gxlhxec.h>
void * oima_p;
unsigned long oima_l;
char handler_parms[128];
char schema_uri[URI_LEN] = “file:///u/user01/myschema.xsd”;
void * osr_p;
int osr_l;
int rc, rsn;
if (oima_p = malloc(GXLHXEC_MIN_OIMA_SIZE))
{ /* oima malloc succeeded */
oima_l = GXLHXEC_MIN_OIMA_SIZE;
gxluInitOSRG(oima_p, oima_l,
0,
(void *)handler_parms,
&rc, &rsn);
} /* oima malloc succeeded */
/* Load a schema and create an OSR from it. */
if ((oima_p > 0) && (rc == GXLHXRC_SUCCESS))
{ /* generator initialized */
gxluLoadSchema(oima_p,
schema_uri,
&rc, &rsn);
if (rc == GXLHXRC_SUCCESS)
{ /* schema load succeeded */
/* Generate the OSR */
osr_l = gxluGenOSR(oima_p,
&osr_p,
&rc, &rsn);
if (osr_l > 0) then
{ /* OSR generate succeeded */
<write the OSR out to a persistent repository>
<like a file or a database so that it can be>
<used later for parsing a document>
...
} /* OSR generate succeeded */
...
} /* schema load succeeded */
...
} /* generator initialized */
This utility will allocate the buffer used to receive the generated OSR, and will return the length of the buffer as its return value. The maximum length of an OSR that will be returned is 2 GB. The buffer remains allocated for the duration of the OSR generator instance, and gets freed when the instance is terminated. The caller may use or copy the OSR to another location as long as the instance is active. Referencing the OSR buffer after the generator instance has been terminated may result in unpredictable results. This buffer may also be written to a permanent location, such as a z/OS® UNIX file or an MVS™ data set, so that it can be used again at some point in the future.