IBM Books

XML Extender Administration and Programming

Planning

Before you begin working with the XML Extender to compose your documents, you need to determine the structure of the XML document and how it corresponds to the structure of your database data. This section will provide an overview of the XML document structure that the service department has requested, of the DTD you will use to define the structure of the XML document, and how this document maps to the columns that contain the data used to populate the documents.

Determining the document structure

The XML document structure takes information for a specific order from multiple tables and creates an XML document for the order. These tables each contain related information about the order and can be joined on their key columns. The service department wants a document that is structured by the order number as the top level, and then customer, part, and shipping information. They want the document structure to be intuitive and flexible, with the elements describing the data, rather than the structure of the document. (For example, the customer's name should be in an element called "customer," rather than a paragraph.) Based on their request, the hierarchical structure of the DTD and the XML document should be like the one described in Figure 5.

After you have designed the document structure, you should create a DTD to describe the structure of the XML document. This tutorial provides an XML document and a DTD for you. You can see the DTD file in Appendix B, Samples. You can see that it matches the structure in Figure 5.

Figure 5. The hierarchical structure of the DTD and XML document


The hierarchical structure of the DTD and XML document

Mapping the XML document and database relationship

After you have designed the structure and created the DTD, you need to show how the structure of the document relates to the DB2 tables that you will use to populate the elements and attributes. You can map the hierarchical structure to specific columns in the relational tables, as in Figure 6.

Figure 6. XML document mapped to relational table columns


XML document mapped to relational table columns

Use this relationship description to create DAD files that define the relationship between the relational data and the XML document structure.

To create the XML collection DAD file, you need to understand how the XML document corresponds to the database structure, as described in Figure 6, so that you can describe from what tables and columns the XML document structure derives data for elements and attributes. You will use this information to create the DAD file for the XML collection.

For this tutorial, we provide a set of scripts for you to use to set up your environment. These scripts are in the DXX_INSTALL\samples\cmd directory (where DXX_INSTALL is the drive and directory where you installed the XML Extender, for example c:\dxx\samples\cmd), and they are as follows:

getstart_db.cmd
Creates the database and populates four tables.

getstart_prep.cmd
Binds the database with the XML Extender stored procedures and the DB2 CLI.

getstart_stp.cmd
Runs the stored procedure to compose the XML collection.

getstart_exportXML.cmd
Exports the XML document from the database for use in an application.

getstart_clean.cmd
Cleans up the tutorial environment.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]