Traditional SQL data is either decomposed from incoming XML documents or used to compose outgoing XML documents. If your data is to be shared with other applications, you might want to be able to compose and decompose incoming and outgoing XML documents and manage the data as necessary to take advantage of the relational capabilities of DB2. This type of XML document storage is called XML collection.
An example of an XML collection is shown in Figure 3.
Figure 3. Storing documents as untagged data in DB2 tables
![]() |
The XML collection is defined in a DAD file, which specifies how elements and attributes are mapped to one or more relational tables. You can define a collection name by enabling it, and then use it with stored procedures to compose or decompose XML documents.
When you define a collection in the DAD file, you use one of two types of mapping schemes, SQL mapping or RDB_node mapping. SQL mapping uses SQL SELECT statements to define the DB2 tables and conditions uses for the collection. RDB_node mapping uses XPath-based RDB_node to define the tables, columns, and conditions.
Stored procedures are provided to compose or decompose XML documents. The stored procedures use the prefix db2xml, which is the schema name of the XML Extender. Use the following stored procedures with XML collections:
The following terms are unique to the XML Extender and are used frequently in this book.