XML schema management with the XML schema repository (XSR)

A DB2® for z/OS® XML schema repository (XSR) is a set of DB2 tables where you can store XML schemas.

DB2 creates the XSR tables during installation or migration. After you add XML schemas to the DB2 XSR, you can use them to validate XML documents before you store them in XML columns.

When you validate an XML document against a schema, DB2 returns a binary representation of the document, which includes default values and normalized text. XML schemas contain data type information for the data that is stored in an XML value, but DB2 for z/OS does not use or store that data type information.

Start of changeAn XML schema consists of a set of XML schema documents. To add an XML schema to the DB2 XSR, you register XML schema documents to DB2. The XML schema documents must be in the Unicode encoding scheme.End of change

You can register an XML schema in any of the following ways:
  • Call the following DB2-supplied stored procedures from a DB2 application program:
    SYSPROC.XSR_REGISTER
    Begins registration of an XML schema. You call this stored procedure when you add the first XML schema document to an XML schema.
    SYSPROC.XSR_ADDSCHEMADOC
    Adds additional XML schema documents to an XML schema that you are in the process of registering. You can call SYSPROC.XSR_ADDSCHEMADOC only for an existing XML schema that is not yet complete.
    SYSPROC.XSR_COMPLETE
    Completes the registration of an XML schema.

    During XML schema completion, DB2 resolves references inside XML schema documents to other XML schema documents.

  • Invoke the following JDBC method from a Java application program:
    com.ibm.db2.jcc.DB2Connection.registerDB2XmlSchema
    Performs the functions of SYSPROC.XSR_REGISTER, SYSPROC.XSR_ADDSCHEMADOC, and SYSPROC.XSR_COMPLETE.
  • Invoke the following commands from the Command Line Processor:
    REGISTER XMLSCHEMA
    Begins registration of an XML schema. You invoke this command when you add the first XML schema document to an XML schema.
    ADD XMLSCHEMA DOCUMENT
    Adds additional XML schema documents to an XML schema that you are in the process of registering. You can invoke -ADD XMLSCHEMA DOCUMENT only for an existing XML schema that is not yet complete.
    COMPLETE XMLSCHEMA
    Completes the registration of an XML schema.
To remove an XML schema from the DB2 XSR, you can use one of the following techniques:
  • Call the following DB2-supplied stored procedure SYSPROC.XSR_REMOVE from a DB2 application program.
  • Invoke the JDBC method com.ibm.db2.jcc.DB2Connection.deregisterDB2XMLObject from a Java application program.