XSR_GET_PARSING_DIAGNOSTICS stored procedure
The stored procedure XSR_GET_PARSING_DIAGNOSTICS generates detailed error information that occur when parsing or validating an XML document. This stored procedure can be used to report both parsing and validation errors or only parsing errors.
Call the XSR_GET_PARSING_DIAGNOSTICS stored procedure from the Db2® command window or add the stored procedure to an application when an error occurs during parsing or validating XML files. For example when validating an XML document using the XMLVALIDATE scalar function, use this stored procedure to generate detailed information about errors that occur during validation.
Syntax
The schema of the stored procedure is SYSPROC.
Authorization
- USAGE privilege on the XML schema that is to be used for validation
- DBADM authority
Procedure parameters
- instance
- An input argument of type BLOB(30M) that contains the content of the XML document. A XML document must be provided. The value cannot be NULL.
- rschema
- An input argument of type VARCHAR(128) that specifies the SQL schema part of the two-part XSR object name registered with the XML schema repository. The value can be NULL. If this value is NULL, the SQL schema part is assumed to be the current value of the CURRENT SCHEMA special register.
- name
- An input argument of type VARCHAR(128) that specifies the schema name of the two-part XSR object name registered with the XML schema repository. The complete SQL identifier for the XML schema is rschema.name. It should be unique among all objects in the XSR. The value can be NULL.
- schemaLocation
- An input argument of type VARCHAR(1000) that indicates the schema
location of the primary XML schema document. This argument is the
external name of the XML schema, that is, the primary document can
be identified in the XML instance document with the
xsi:schemaLocation
attribute. The value can be NULL. - implicitValidation
- An input argument of type INTEGER that indicates whether the schema
location from the instance document should be used to find the XML
schema. The value cannot be NULL. The possible values are 0 for no
and 1 for yes.
- 0
- Do not use schema location from the instance document. If a 0
value is passed you can specify the schema in using one of the following
methods:
- Provide the XSR object name as arguments rschema and name for schema that is registered in the XML schema repository.
- Provide the schema location using the argument schemaLocation
If both the XSR object name and the schemaLocation are specified, the XSR object name is used. If neither are specified validation is not performed. Only an XML parse is performed and any XML parsing errors are reported.
- 1
- Use schema location from the value of the
xsi:schemaLocation
attribute in the instance document.
Validation is performed on the input document against XML schema documents previously registered with the XML schema repository.
The instance document is parsed without validation if value of implicitValidation argument is 0 and the value of the rschema, name, and schemaLocation arguments are NULL.
- errorDialog
- An output argument of type VARCHAR(32000) that contains a UTF-8 XML document that lists parsing and validation errors. The document is generated only when there is at least one error. See the related reference at the end of this topic for information about the format of the XML document.
- errorCount
- An output argument of type INTEGER that specifies the total number of XML parsing and validation errors.
Usage
- Provide the XSR object name for the XML schema using the rschema and name arguments.
- Provide the schema location using the schemaLocation argument.
- Set implicitValidation to 1 if the XML instance
document specifies the schema as the value of the
xsi:schemaLocation
attribute.
If a parsing or validation error occurs when using the XSR_GET_PARSING_DIAGNOSTICS stored procedure, errorDialog and errorCount output parameters are set. The errorDialog contains an XML document that lists the errors. You can call the XSR_GET_PARSING_DIAGNOSTICS stored procedure from applications that use CLI , Java™ or C++ and use a parameter marker to get the output of the stored procedure.