Registering XSR objects through stored procedures

When a database is created, the stored procedures used to register XML schemas are also created. To register XML schemas through the stored procedure method, invoke the XSR_REGISTER, XSR_ADDSCHEMADOC and XSR_COMPLETE stored procedures with the CALL statement.

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

Registering XML schemas:

  1. Register the primary XML schema document by calling the SYSPROC.XSR_REGISTER stored procedure:
    CALL SYSPROC.XSR_REGISTER ('user1', 'POschema', 'http://myPOschema/PO',
                                :content_host_var, NULL)
  2. Before completing the registration, add any additional XML schema documents to be included with the primary XML schema. Note that each additional schema document can be included only once. For our example, this step is not optional, since the XML schema consists of two XML schema documents, both of which must be registered. Use the XSR_ADDSCHEMADOC stored procedure to add additional XML schema documents. The following example shows how to add the schema constructs for addresses to the XSR object:
    CALL SYSPROC.XSR_ADDSCHEMADOC ('user1', 'POschema', 'http://myPOschema/address',
                                :content_host_var, NULL)
  3. Complete registration by calling the SYSPROC.XSR_COMPLETE stored procedure. In the following example, the last parameter indicates that the XML schema will not be used for decomposition (a value of 1 would indicate that it will be used for decomposition):
    CALL SYSPROC.XSR_COMPLETE ('user1', 'POschema', :schemaproperty_host_var, 0)

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 USAGE privilege for an XSR object is automatically granted to the creator of the XSR object.