XMLXSROBJECTID
The XMLXSROBJECTID function returns the XSR object identifier of the XML schema that is used to validate the XML document specified in the argument.
The schema is SYSIBM.
- xml-value-expression
- An expression that results in a value with a data type of XML. The resulting XML value must be an XML sequence with a single item that is an XML document or the null value.
The XSR object identifier is returned as a BIGINT value and provides the key to a single row in the SYSIBM.XSROBJECTS table.
The result can be null; if the argument is null, the result is the null value.
If xml-value-expression does not specify a validated XML document, the function returns 0.
Note: The XML schema that corresponds to an XSR object ID
returned by the function might no longer exist, because an XML schema
can be dropped without affecting XML values that were validated using
that XML schema. Therefore, queries that use the XSR object ID to
fetch further XML schema information from the SYSIBM.XSROBJECTS table
might return an empty result set.
- Example 1: Use the XMLXSROBJECTID function in conjunction with the DSN_XMLVALIDATE function to find all XML documents that are not validated in a table and validate them:
UPDATE orders SET content = dsn_xmlvalidate(content, 'SYSXSR.PO1') WHERE XMLXSROBJECTID(content) = 0;
- Example 2: Use the XMLXSROBJECTID function to find the names and target namespaces of the XML schemas that are used to validate the XML documents in a table:
SELECT DISTINCT s.XSROBJECTNAME, s.targetNamespace FROM orders o, XSROBJECTS s WHERE XMLXSROBJECTID(content) = s.XSROBJECTID;