Registering XSR objects through the command line processor

To register XML schemas through the command line processor, use the REGISTER XMLSCHEMA, ADD XMLSCHEMA DOCUMENT and COMPLETE XMLSCHEMA commands.

An XML schema document is not checked for correctness when registering or adding documents. Document checks are performed only when you complete schema registration.

Note that you cannot use CLP commands to register XML schemas from host applications, because the required file information cannot be passed through these commands. In order to register XML schemas from applications connecting to a Db2® database through a CLI/ODBC or JDBC driver, use the stored procedure method.

Registering XML schemas:

  1. Register the primary XML schema document by issuing the REGISTER XMLSCHEMA command:
    REGISTER XMLSCHEMA 'http://myPOschema/PO'
    FROM 'file://c:/TEMP/PO.xsd'
    AS user1.POschema
  2. Before completing the registration, you may optionally add additional XML schema documents to be included with the primary XML schema. Use the ADD XMLSCHEMA DOCUMENT command to add additional XML schema documents. Note that each additional schema document can be included only once. The following example shows how to add the schema constructs for addresses to storage:
    ADD XMLSCHEMA DOCUMENT TO user1.POschema
       ADD 'http://myPOschema/address'
       FROM 'file://c:/TEMP/address.xsd'
  3. Complete registration by issuing the COMPLETE XMLSCHEMA command:
    COMPLETE XMLSCHEMA user1.POschema
    WITH 'file://c:TEMP/schemaProp.xml'

Privileges

Any user with DBADM authority can register an XML schema. For all other users, the privileges are based on the SQL schema that is supplied during the registration process. If the SQL schema does not exist, then IMPLICIT_SCHEMA authority on the database is required to register the schema. If the SQL schema exists, then the user registering the schema needs CREATEIN privilege on the SQL schema.

The USE privilege for XSR objects is automatically granted to the creator of the XSR object.