DSN_XMLVALIDATE

The DSN_XMLVALIDATE function returns an XML value that is the result of applying XML schema validation to the first argument of the function. DSN_XMLVALIDATE can validate XML data that has a maximum length of 2 GB - 1 byte.

>>-DSN_XMLVALIDATE(-+-string-expression-+-,-+-schema-name-string---------------------------------+-)-><
                    '-xml-expression----'   '-target-namespace-uri-string,schema-location-string-'     

The schema is SYSIBM.

string-expression
An expression that returns a built-in character, graphic, or binary string. The value must be a well-formed XML document that conforms to the XML Version 1.0 standard.
Start of changexml-expressionEnd of change
Start of changeAn expression that returns an XML value in the XML data type. The value must be a well-formed XML document that conforms to XML Version 1.0 standard.End of change
schema-name-string
An expression that returns a built-in varying length character string that is not a CLOB. The value specifies the name of the XML schema object that is used for validation. The value must not be an empty string or the null value, and the actual length must be less than or equal to 257. If the XML schema name is qualified, the qualifier must be SYSXSR (SYSXSR is the default qualifier). The value must identify a registered XML schema in the DB2® XML schema repository.
target-namespace-uri-string
An expression that returns a built-in varying length character string that is not a CLOB, with a length attribute that is not greater than 1000. The value specifies the target namespace name or universal resource identifier (URI) of the XML schema that is to be used for validation. If the value is an empty string of the null value, no namespace is used to locate the XML schema.
schema-location-string
An expression that returns a built-in varying length character string that is not a CLOB, with a length attribute that is not greater than 1000. The value specifies the XML schema location hint URI of the XML schema that is to be used for validation. If the value is an empty string of the null value, no schema location is used to locate the XML schema.

If target-namespace-uri-string and schema-location-string are specified, the combination must identify a registered XML schema in the DB2 XML schema repository, and there must be only one such registered XML schema.

A schema must be registered successfully in the DB2 XML schema repository before it can be used for DSN_XMLVALIDATE. If the validation fails, DB2 returns an error.

The result of the function is an XML value.

The result can be null; if the first argument is null, the result is the null value.

Example 1: The following example shows how the DSN_XMLVALIDATE function validates the XML data that is contained in the value_host_var host variable. The XML schema, SYSXSR.ORDERSCHEMA, was registered prior to this statement:
   INSERT INTO T1(C1) VALUES(
   	DSN_XMLVALIDATE(:value_host_var, 'SYSXSR.MYXMLSCHEMA'));
Example 2: The following example is similar to the previous example but references the namespace and schema location:
   INSERT INTO T1(C1) VALUES(
   	DSN_XMLVALIDATE(:value_host_var,
                           'http://www.n1.com',
                           'http://www.n1.com/report.xsd'));