How to determine whether an XML document has been validated
You can use the SQL XMLXSROBJECTID scalar function to determine whether an XML document that is stored in a table has undergone XML validation, and which XML schema was used to validate that document.
XMLXSROBJECTID returns the XSR object identifier of the XML schema that was used to validate the input XML document. The XSR object identifier corresponds to the XSROBJECTID column in the SYSIBM.XSROBJECTS catalog table. After you call XMLXSROBJECTID, you can use the returned value to query SYSIBM.XSROBJECTS for the XML schema information. If the XML document has not been validated, XMLXSROBJECTID returns 0.
Examples
Example: The following SQL statement calls XMLXSROBJECTID to determine which XML documents in the INFO column of the CUSTOMER table have not been validated. The statement then calls DSN_XMLVALIDATE to validate those documents against XML schema SYSXSR.P01.
UPDATE CUSTOMER
SET INFO = DSN_XMLVALIDATE(INFO, 'SYSXSR.PO1')
WHERE XMLXSROBJECTID(INFO)=0Example: The following SQL statement retrieves the target namespaces and XML schema names for the XML schemas that were used to validate XML documents in the INFO column of the CUSTOMER table.
SELECT DISTINCT S.XSROBJECTNAME, S.TARGETNAMESPACE
FROM CUSTOMER C, XSROBJECTS S
WHERE XMLXSROBJECTID(INFO) = S.XSROBJECTID