When you want to store pieces of an XML document in columns
of one or more tables, you can use annotated XML schema decomposition.
This type of decomposition breaks an XML document down for storage
in tables, based on the annotations specified in a registered annotated
XML schema.
About this task
To decompose XML documents using annotated XML schemas:
Procedure
- If you are using a database created from earlier versions
of DB2® database
products,
run the BIND command using the list file xdb.lst,
which is found in the sqllib/bnd directory.
- Annotate the schema documents with XML
decomposition annotations.
- Register the schema
documents and enable the schema for decomposition.
- If any of the registered schema documents that belongs
to the XML schema have changed, then all documents for this XML schema
must be registered again and the XML schema must be enabled for decomposition.
- Depending on the location of the XML
document to be decomposed, use one of the methods indicated, providing
the XSR object name for the XML schema:
- For a single XML document is on the file system, use one of
the following methods:
- Call one of the XDBDECOMPXML stored procedures that is just large
enough for the size of the document being decomposed. 1
- Issue the DECOMPOSE XML DOCUMENT command.
- For one or more documents are stored in a binary or XML column,
use one of the following methods:
- Issue the DECOMPOSE XML DOCUMENTS command.
- Call the XDB_DECOMP_XML_FROM_QUERY stored procedure.
1 If you are
using scripts or applications to decompose several documents of which
the size is unknown, consider using the DECOMPOSE XML DOCUMENT command
to decompose, rather than the XDBDECOMPXML stored procedure, as the
command automatically calls the stored procedure appropriate for the
size of the document.