Generating DAD files

Once you have mapped the columns to the DTD file, you can generate and test a DAD file. To test the DAD file, have the DB2 XML Extender installed and configured.

Note: If you are generating DAD files for the DB2 XML Extender on DBCS machines, the DAD files should be generated in the platform's default encoding to run properly. You can do this by selecting the proper encoding value from the XML file preferences editor Window > Preferences > Web and XML > XML Files and select the Encoding field.)

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

To generate the DAD file, follow these steps:

  1. Double-click your .rmx file in the Navigator view to open the mapping session file in the RDB to XML mapping editor.

  2. Select Mapping > Generate DAD to start the Generate DAD wizard.

    If you are generating a DAD from an SQL mapping, a dialog may appear to warn you that an invalid DAD file may be created if you have unmapped text nodes. You can cancel and map the unmapped nodes, or click Continue to create the DAD file anyway.

    If you are generating a DAD from a relational table mapping, a warning dialog may appear if you have multiple tables and have not specified join conditions. Click Edit Joins to return to the mapping editor and create the necessary join conditions in the Edit Join Conditions dialog, or click Continue to create the DAD file anyway.

  3. Select the folder that you wish to contain your DAD file.

  4. Type the name of the DAD file, for example: MyDAD.dad . Your filename must end in .dad. If there is already a DAD file with that name, it will be overwritten when the new DAD file is generated.

  5. Click Next. The DAD Generation Advanced Options page opens.

  6. (This step is optional) If the root element of your target XML document has an attribute, or can contain PCDATA, the DB2 XML Extender query will return multiple XML documents. Select Enclose entire document with a new root element tag to add a new tag to the XML document that will enclose the contents of the file so the XML Extender query result is returned as a single XML document. Specify the tag name, then click Next.

    Note: If you select this option for an RDB_node mapping DAD, you will be able to retrieve XML content, but will not be able to store XML content in the database.

  7. If you wish to create your DAD file without generating a test harness, click Finish.

  8. To generate a test harness to test your script, select the Generate test harness check box. A test harness is a series of script files used to enable a DB2 database for use by the DB2 XML Extender. Once enabled, it tests composing XML from data as well as decomposing XML files into relational data.

  9. Type the path of the DB2 SQLLIB directory, for example c:\program files\SQLLIB

  10. Type the path of the DB2 XML Extender directory, for example c:\dxx. If you are working with DB2 UDB Version 8.1, this field will not appear as Version 8.1 includes DB2 XML Extender.

  11. In the XMLDIR text field, type the path of the directory in which you want the output XML file to be created. This is the same directory where the source XML files used to store information in the database are located.

  12. Select the radio button that corresponds to the destination platform (the platform on which the test harness will be executed), then click Finish.

Your DAD file is generated. If necessary, you can modify the script. See Editing DAD files for more details.

DAD script
The relational database (RDB) to XML mapping editor generates a document access definition (DAD) file that can be used with the IBM DB2 XML Extender to generate XML documents from existing relational data, or to decompose XML documents into relational data. The DAD file, also referred to as a DAD script, is an XML formatted document that associates an XML document structure with tables in a DB2 database.

Editing DAD files
You may want to edit a DAD file if you have moved your document type definition (DTD) file, or need to otherwise modify the output of the DAD Generator.

Running DAD files with the DB2 XML Extender
Once you have generated your DAD file, you can run it with the IBM DB2 XML Extender.

 

Parent topic

Mapping from relational databases to XML files

 

Related concepts

DAD script

 

Related tasks

Editing DAD files
Running DAD files with the DB2 XML Extender

Related reference
The generated DAD script