Registering and enabling XML schemas for decomposition

Once an annotated schema has been successfully registered and enabled for decomposition, you can use it to decompose XML documents.

Before you begin

  • Ensure that at least one element or attribute declaration in the XML schema is annotated with an XML decomposition annotation. This annotated element or attribute must be a descendant of, or itself be, a global element of complex type.
  • Ensure all tables and columns referenced in the set of annotated schema documents that compose the XML schema exist in the database. A dependency is created between each table referenced in the schema and the XSR object that corresponds to this schema.
  • Ensure that the applheapsz configuration parameter is set to at least 1024.

Procedure

Choose one of the following methods to register and enable XML schemas for decomposition:1

  • Stored procedures:
    1. Call the XSR_REGISTER stored procedure, passing in the primary schema document.
    2. If the XML schema consists of more than one schema document, call the XSR_ADDSCHEMADOC stored procedure for each of the schema documents that have not yet been registered.
    3. Call the XSR_COMPLETE stored procedure with the isusedfordecomposition parameter set to 1.
  • Command line:
    • If the XML schema consists of only one schema document, issue the REGISTER XML SCHEMA command with the COMPLETE and ENABLE DECOMPOSITION options.
    • If the XML schema consists of more than one schema document:
      1. For each schema document except the last, issue the REGISTER XML SCHEMA command.
      2. For the last schema document that has not yet been registered, issue the REGISTER XML SCHEMA command with the COMPLETE and ENABLE DECOMPOSITION options.
  • JDBC interface:
    1. Call the DB2Connection.registerDB2XMLSchema method and set the isUsedForDecomposition boolean parameter to true to enable decomposition.2

What to do next

When an XML schema is enabled for decomposition, a dependency is created between each table referenced in the schema and the XSR object that corresponds to this schema. This dependency prevents any table referenced in the schema from being renamed. The XSR object for the XML schema must be disabled for decomposition in order for a referenced table to be renamed. The tables referenced by XSR objects can be found in the SYSCAT.XSROBJECTDEP catalog view.

1 If the XML schema was previously registered using any of these methods, but not enabled for decomposition, you can enable the schema for decomposition by issuing the ALTER XSROBJECT SQL statement with the ENABLE DECOMPOSITION option.
2 This method exists in two forms: one form for XML schema documents that are input from an InputStream object, and one form for XML schema documents that are in a String.