XML Extender Administration and Programming
Creating a DAD file is required when using XML collections. A DAD
file defines the relationship between XML data and multiple relational
tables. The XML Extender uses the DAD file to:
- Compose an XML document from relational data
- Decompose an XML document to relational data
You can use either of two methods to map the data between the XML tables
and the DB2 table: SQL mapping and RDB_node mapping:
- SQL mapping
- Uses an SQL statement element to specify the SQL query for tables and
columns that are used to contain the XML data. SQL mapping can be used
for composing XML documents, only.
- RDB_node mapping
- Uses an XML Extender-unique element, Relational Database node, or
RDB_node, which specifies tables, columns, conditions, and the order for XML
data. RDB_node mapping supports more complex mappings than an SQL
statement can provide. RDB_node mapping can be used for both composing
and decomposing XML documents.
Both methods of mapping use the XPath data model, which is
described in The DAD file.
- Map the relationship between your DB2 tables and the XML document.
This step should include mapping the hierarchy of the XML document and
specifying how the data in the document maps to a DB2 table.
- If you plan to validate the XML documents, insert the DTD for the XML
document you are composing or decomposing into the DTD reference table,
db2xml.DTD_REF.
Use SQL mapping when you are composing XML documents and want to use
SQL.
Use the following steps to create a DAD file using XML collection SQL
mapping
To create a DAD file for composition using SQL mapping:
Use SQL mapping when you are composing XML documents and you want to use an
SQL statement to define the table and columns from which you will derive the
data in the XML document.
- Set up and start the administration wizard. See Starting the administration wizard for details.
- Click Work with DAD files from the LaunchPad window. The
Specify a DAD windows is displayed.
- Choose whether to edit an existing DAD file or to create a new DAD
file.
To create a new DAD file:
- Leave the File name field blank.
- From the Type menu, select XML collection SQL
mapping.
- Click Next to open the Select Validation window.
To edit an existing DAD file:
- Type the DAD file name into the File name field, or click
... to browse for an existing DAD file.
- Verify that the wizard recognizes the specified DAD file.
- If the wizard recognizes the specified DAD file, Next is
selectable and XML collection SQL mapping is displayed in the Type
field.
- If the wizard does not recognize the specified DAD file, Next
is not selectable. Either retype the DAD file name, or click
... to browse again for an existing DAD
file. Correct the values of the entry field until Next is
selectable.
- Click Next to open the Select Validation window.
- In the Select Validation window, choose whether to validate your XML
documents with a DTD.
- Click Next to open the Specify Text window.
- Type the prolog name in the Prolog field, to specify the prolog
of the XML document to be composed.
<?xml version="1.0" ?>
If you are editing an existing DAD, the prolog is automatically displayed
in the Prolog field.
- Type the document type of the XML document in the Doctype field
of the Specify Text window, pointing to the DTD for the XML document.
For example:
! DOCTYPE DAD SYSTEM "c:\dxx\samples\dtd\getstart.dtd"
If you are editing an existing DAD, the document type is automatically
displayed in the Doctype field.
- Click Next to open the Specify SQL Statement window.
- Type a valid SQL SELECT statement in the SQL statement
field. For example:
SELECT o.order_key, customer_name, customer_email, p.part_key, color, quantity,
price, tax, ship_id, date, mode from order_tab o, part_tab p,
table (select substr(char(timestamp(generate_unique())),16)
as ship_id, date, mode, part_key from ship_tab) s
WHERE o.order_key = 1 and
p.price > 20000 and
p.order_key = o.order_key and
s.part_key = p.part_key
ORDER BY order_key, part_key, ship_id
If you are editing an existing DAD, the SQL statement is automatically
displayed in the SQL statement field.
- Click Test SQL to test the validity of the SQL
statement.
- If your SQL statement is valid, sample results are displayed in the
Sample results field.
- If your SQL statement is not valid, an error message is displayed in the
Sample results field. The error message instructs you to
correct your SQL SELECT statement and to try again.
- Click Next to open the SQL Mapping window.
- Select an element or attribute node to map from by clicking on it in the
field on the left of the SQL Mapping window.
Map the elements and attributes in the XML document to element and
attribute nodes that correspond to DB2 data. These nodes provide a path
from the XML data to the DB2 data.
- Type the name of an output file for the modified DAD file in the File
name field of the Specify a DAD window.
- Click Finish to return to the LaunchPad window.
Use SQL mapping notation when you are composing XML document and want to
use SQL.
The DAD file is an XML file that you can create using any text
editor. The following steps show fragments from the samples appendix, Document access definition files. Please refer to these examples for more
comprehensive information and context.
- Open a text editor.
- Create the DAD header:
<?xml version="1.0"?>
<!DOCTYPE DAD SYSTEM "path\dad.dtd"> --> the path and file name of the DTD
for the DAD
- Insert the <DAD></DAD> tags.
- After the <DAD> tag, specify the DTD ID that associates the DAD file
with the XML document DTD.
<dtdid>path\dtd_name.dtd> --> the path and file name
of the DTD for your application
- Specify whether to validate (that is, to use a DTD to ensure that the XML
document is a valid XML document). For example:
<validation>NO</validation> --> specify YES or NO
- Use the <Xcollection> element to define the access and storage method
as XML collection. The access and storage methods define that the XML
document will have content derived from data stored in DB2 tables.
<Xcollection>
</Xcollection>
- Specify one or more SQL statements to query or insert data from or into
DB2 tables. See Mapping scheme requirements for guidelines. For example, you
specify a single SQL query like in the following example:
<SQL_stmt>
SELECT o.order_key, customer_name, customer_email, p.part_key, color, quantity,
price, tax, ship_id, date, mode from order_tab o, part_tab p,
table (select substr(char(timestamp(generate_unique())),16)
as ship_id, date, mode, part_key from ship_tab) s
WHERE o.order_key = 1 and
p.price > 20000 and
p.order_key = o.order_key and
s.part_key = p.part_key
ORDER BY order_key, part_key, ship_id
</SQL_stmt>
- Add the following prolog information:
<prolog>?xml version="1.0"?</prolog>
This exact text is required.
- Add the <doctype></doctype> tags. For example:
<doctype>! DOCTYPE Order SYSTEM "c:\dxx\samples\dtd\getstart.dtd"</doctype>
- Define the root node using the <root_node></root_node> tags.
Inside the root_node, you specify the elements and attributes that make up the
XML document.
- Map the elements and attributes in the XML document to element and
attribute nodes that correspond to DB2 data. These nodes provide a path
from the XML data to the DB2 data.
- Define an <element_node> for each element in your XML document that
maps to a column in a DB2 table.
<element_node name="name"></element_node>
An element_node can have the following nodes.
- attribute_node
- child element_node
- text_node
- Define an <attribute_node> for each attribute in your XML document that
maps to a column in a DB2 table. See the example DTDs at the beginning
of this section for SQL mapping, as well as the DTD for the DAD file in Appendix A, DTD for the DAD file, which provides the full syntax for the DAD file.
For example, you need an attribute key for an element <Order>.
The value of key is stored in a column PART_KEY.
DAD file: In the DAD file, create an attribute node for
key and indicate the table where the value of 1 is to be stored.
<attribute_node name="key">
<column name="part_key"/>
</attribute_node>
Composed XML document: The value of key is taken from the
PART_KEY column.
<Order key="1">
- Create a <text_node> for every element or attribute that has content
that will be derived from a DB2 table. The text node has a <column>
element that specifies from which column the content is provided.
For example, you might have an XML element <Tax> with a value that will
be taken from a column called TAX:
DAD element:
<element_node name="Tax">
<text_node>
<column name="tax"/>
</text_node>
</element_node>
The column name must be in the SQL statement at the beginning of the DAD
file.
Composed XML document:
<Tax>0.02</Tax>
The value 0.02 will be derived from the column
TAX.
- Ensure that you have an ending </root_node> tag after the last
</element_node> tag.
- Ensure that you have an ending </Xcollection> tag after the
</root_node> tag.
- Ensure that you have an ending </DAD> tag after the </Xcollection>
tag.
Use RDB_node mapping to compose XML documents using a XML-like
structure.
This method uses the <RDB_node> to specify DB2 tables, column, and
conditions for an element or attribute node. The <RDB_node> uses the
following elements:
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding element
- <condition>: optionally specifies a condition on the column
The child elements that are used in the <RDB_node> depend on the context
of the node and use the following rules:
If the node type is:
| RDB child element is used:
|
| Table
| Column
| Condition1
|
---|
Root element
| Y
| N
| Y
|
Attribute
| Y
| Y
| optional
|
Text
| Y
| Y
| optional
|
(1) Required with multiple tables
|
To create a DAD for composition, using RDB_node mapping:
- Set up and start the administration wizard. See Starting the administration wizard for details.
- Click Work with DAD files from the LaunchPad window. The
Specify a DAD window is displayed.
- Choose whether to edit an existing DAD file or to create a new DAD.
To edit an existing DAD:
- Type the DAD file name into the File name field or click
... to browse for an existing DAD.
- Verify that the wizard recognizes the specified DAD file.
- If the wizard recognizes the specified DAD file, Next is
selectable, and XML collection RDB node mapping is displayed in the
Type field.
- If the wizard does not recognize the specified DAD file, Next
is not selectable. Either retype the DAD file name into the File
name field or click ... to browse again
for an existing DAD file. Continue these steps until Next is
selectable.
- Click Next to open the Select Validation window.
To create a new DAD:
- Leave the File name field blank.
- Select XML collection RDB_node mapping from the Type
menu.
- Click Next to open the Select Validation window.
- In the Select Validation window, choose whether to validate your XML
documents with a DTD.
- Click Next to open the Specify Text window.
- Type the prolog name in the Prolog field of the Specify Text
window.
<?xml version="1.0" ?>
If you are editing an existing DAD, the prolog is automatically displayed
in the Prolog field.
- Enter the document type of the XML document in the Doctype
field of the Specify Text window.
If you are editing an existing DAD, the document type is automatically
displayed in the Doctype field.
- Click Next to open the RDB Mapping window.
- Select an element or attribute node to map from by clicking on it in the
field on the left of the RDB Mapping window.
Map the elements and attributes in the XML document to element and
attribute nodes which correspond to DB2 data. These nodes provide a
path from the XML data to the DB2 data.
- To add the root node:
- Select the Root icon.
- Click New Element to define a new node.
- In the Details box, specify Node type as
Element.
- Enter the name of the top level node in the Node name
field.
- Click Add to create the new node.
You have create the root node or element, which is the parent to all the
other element and attribute nodes in the map. The root node has table
child elements and a join condition.
- Add table nodes for each table that is part of the collection.
- Highlight the root node name and select New Element.
- In the Details box, specify Node type as
Table.
- Select the name of the table from Table name. The table
must already exist.
- Click Add to add the table node.
- Repeat these steps for each table.
- Add a join condition for the table nodes.
- Highlight the root node name and select New Element.
- In the Details box, specify Node type as
Condition.
- In the Condition field, enter the join condition using the
following syntax:.
table_name.table_column = table_name.table_column AND
table_name.table_column = table_name.table_column ...
- Click Add to add the condition.
- To add an element or attribute node:
- Click on a parent node in the field on the left to add a child element or
attribute.
- Click New Element. If you have not selected a parent
node, New Element is not selectable.
- Select a node type from the Node type menu in the
Details box.
The Node type menu displays only the node types that are valid
at that point in the map. Element or
Attribute.
- Specify a node name in the Node name field.
- Click Add to add the new node.
- To map the contents of an element or attribute node to a relational
table:
- Specify a text node.
- Click the parent node.
- Click New Element.
- In the Node type field, select Text.
- Select Add to add the node.
- Add a table node.
- Select the text node you just created and click New
Element.
- In the Node type field, select Table and specify a
table name for the element.
- Click Add to add the node.
- Add a column node.
- Select the text node again and click New Element.
- In the Node type field, select Column and specify a
column name for the element.
- Click Add to add the node.
Restriction: New columns cannot be created using the
administration wizard. If you specify Column as the node type, you can
only select a column that already exists in your DB2 database.
- Optionally add a condition for the column.
- Select the text node again and click New Element.
- In the Node type field, select Condition and the
condition with the syntax:
operator LIKE|<|>|= value
- Click Add to add the node.
- Continue editing the RDB map or click Next to open the Specify
a DAD window.
- To remove a node:
- Click on a node in the field on the left.
- Click Remove.
- Continue editing the RDB_node map or click Next to open the
Specify a DAD window.
- Type in an output file name for the modified DAD in the File
name field of the Specify a DAD window.
- Click Finish to remove the node and return to the LaunchPad
window.
The DAD file is an XML file that you can create using any text
editor. The following steps show fragments from the samples appendix, Document access definition files. Please refer to these examples for more
comprehensive information and context.
- Open a text editor.
- Create the DAD header:
<?xml version="1.0"?>
<!DOCTYPE DAD SYSTEM "path\dad.dtd"> --> the path and file name of the DTD
for the DAD
- Insert the <DAD></DAD> tags.
- After the <DAD> tag, specify the DTD ID that associates the DAD file
with the XML document DTD.
<dtdid>path\dtd_name.dtd> --> the path and file name of the DTD
for your application
- Specify whether to validate (that is, to use a DTD to ensure that the XML
document is a valid XML document). For example:
<validation>NO</validation> --> specify YES or NO
- Use the <Xcollection> element to define the access and storage method
as XML collection. The access and storage methods define that the XML
data is stored in a collection of DB2 tables.
<Xcollection>
</Xcollection>
- Add the following prolog information:
<prolog>?xml version="1.0"?</prolog>
This exact text is required.
- Add the <doctype></doctype> tags. For example:
<doctype>! DOCTYPE Order SYSTEM "c:\dxx\samples\dtd\getstart.dtd"</doctype>
- Define the root node using the <root_node>. Inside the
root_node, you specify the elements and attributes that make up the XML
document.
- Map the elements and attributes in the XML document to element and
attribute nodes that correspond to DB2 data. These nodes provide a path
from the XML data to the DB2 data.
- Define a root root element_node. This element_node contains:
- An RDB_node which specifies table_nodes with a join condition to specify
the collection
- Child elements
- Attributes
To specify the table nodes and condition:
- Create an RDB_node element: For example:
<RDB_node>
</RDB_node>
- Define a <table_node> for each table that contains data to be included
in the XML document. For example, if you have three tables, ORDER_TAB,
PART_TAB, and SHIP_TAB, that have column data to be in the document, create a
table node for each. For example:
<RDB_node>
<table name="ORDER_TAB">
<table name="PART_TAB">
<table name="SHIP_TAB"></RDB_node>
- Optionally, specify a key column for each table when you plan to enable
this collection. The key attribute is not normally required for
composition; however, when you enable a collection, the DAD file used
must support both composition and decomposition. For example:
<RDB_node>
<table name="ORDER_TAB" key="order_key">
<table name="PART_TAB" key="part_key">
<table name="SHIP_TAB" key="date mode">
</RDB_node>
- Define a join condition for the tables in the collection. The
syntax is
expression = expression AND
expression = expression
For example:
<RDB_node>
<table name="ORDER_TAB">
<table name="PART_TAB">
<table name="SHIP_TAB">
<condition>
order_tab.order_key = part_tab.order_key AND
part_tab.part_key = ship_tab.part_key
</condition>
</RDB_node>
- Define an <element_node> tag for each element in your XML document that
maps to a column in a DB2 table. For example:
<element_node name="name">
</element_node>
An element node can have one of the following types of elements:
- <text_node>: to specify that the element has content to a DB2
table; the element does not have child elements
- <attribute_node>: to specify an attribute. Attribute nodes
are defined in the next step.
The text_node contains an <RDB_node> to map content to a DB2 table and
column name.
RDB_nodes are used for bottom-level elements that have content to map to a
DB2 table. An RDB_node has the following child elements.
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding element
and specifies the column type with the type attribute
- <condition>: optionally specifies a condition on the column
For example, you might have an XML element <Tax> that maps to a column
called TAX:
XML document:
<Tax>0.02</Tax>
In this case, you want the value 0.02 to be a value in
the column TAX.
<element_node name="Tax">
<text_node>
<RDB_node>
<table name="part_tab"/>
<column name="tax"/>
</RDB_node>
</text_node>
</element_node>
In this example, the <RDB_node> specifies that the value of the
<Tax> element is a text value, the data is stored in the PART_TAB table in
the TAX column.See the example DAD files in Document access definition files for RDB_node mapping, as well as the DTD for the DAD file in
Appendix A, DTD for the DAD file, which provides the full syntax for the DAD file.
- Optionally, add a type attribute to each <column> element when you plan
to enable this collection. The type attribute is not normally required
for composition; however, when you enable a collection, the DAD file used
must support both composition and decomposition. For example:
<column name="tax" type="real"/>
- Define an <attribute_node> for each attribute in your XML document that
maps to a column in a DB2 table. For example:
<attribute_node name="key">
</attribute_node>
The attribute_node has an <RDB_node> to map the attribute value to a DB2
table and column. An <RDB_node> has the following child
elements.
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding element
- <condition>: optionally specifies a condition on the column
For example, you might want to have an attribute key for an
element <Order>. The value of key needs to be stored in a column
PART_KEY. In the DAD file, create an <attribute_node> for key and
indicate the table where the value is to be stored.
DAD file
<attribute_node name="key">
<RDB_node>
<table name="part_tab">
<column name="part_key"/>
<RDB_node>
</attribute_node>
Composed XML document:
<Order key="1">
- Ensure that you have an ending </root_node> tag after the last
</element_node> tag.
- Ensure that you have an ending </Xcollection> tag after the
</root_node> tag.
- Ensure that you have an ending </DAD> tag after the </Xcollection>
tag.
Use RDB_node mapping to decompose XML documents. This method
uses the <RDB_node> to specify DB2 tables, column, and conditions for an
element or attribute node. The <RDB_node> uses the following
elements:
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding element
- <condition>: optionally specifies a condition on the column
The child elements that are used in the <RDB_node> depend on the context
of the node and use the following rules:
If the node type is:
| RDB child element is used:
|
| Table
| Column
| Condition1
|
---|
Root element
| Y
| N
| Y
|
Attribute
| Y
| Y
| optional
|
Text
| Y
| Y
| optional
|
(1) Required with multiple tables
|
To create a DAD for decomposition:
- Set up and start the administration wizard. See Starting the administration wizard for details.
- Click Work with DAD files from the LaunchPad window. The
Specify a DAD windows is displayed.
- Choose whether to edit an existing DAD file or to create a new DAD.
To edit an existing DAD:
- Type the DAD file name into the File name field or click
... to browse for an existing DAD.
- Verify that the wizard recognizes the specified DAD file.
- If the wizard recognizes the specified DAD file, Next is
selectable, and XML collection RDB node mapping is displayed in the
Type field.
- If the wizard does not recognize the specified DAD file, Next
is not selectable. Either retype the DAD file name into the File
name field or click ... to browse again
for an existing DAD file. Continue these steps until Next is
selectable.
- Click Next to open the Select Validation window.
To create a new DAD:
- Leave the File name field blank.
- Select XML collection RDB_node mapping from the Type
menu.
- Click Next to open the Select Validation window.
- In the Select Validation window, choose whether to validate your XML
documents with a DTD.
- Click Next to open the Specify Text window.
- If you are decomposing an XML document only, ignore the Prolog
field. If you are using the DAD file for both composition and
decomposition, type the prolog name in the Prolog field of the
Specify Text window. The prolog is not required if you are decomposing
XML documents into DB2 data.
<?xml version="1.0"?>
If you are editing an existing DAD, the prolog is automatically displayed
in the Prolog field.
- If you are decomposing an XML document only, ignore the Doctype
field. If you are using the DAD file for both composition and
decomposition, enter the document type of the XML document in the
Doctype field
If you are editing an existing DAD, the document type is automatically
displayed in the Doctype field.
- Click Next to open the RDB Mapping window.
- Select an element or attribute node to map from by clicking on it in the
field on the left of the RDB Mapping window.
Map the elements and attributes in the XML document to element and
attribute nodes which correspond to DB2 data. These nodes provide a
path from the XML data to the DB2 data.
- To add the root node:
- Select the Root icon.
- Click New Element to define a new node.
- In the Details box, specify Node type as
Element.
- Enter the name of the top level node in the Node name
field.
- Click Add to create the new node.
You have created the root node or element, which is the parent to all the
other element and attribute nodes in the map. The root node has table
child elements and a join condition.
- Add table nodes for each table that is part of the collection.
- Highlight the root node name and select New Element.
- In the Details box, specify Node type as
Table.
- Select the name of the table from Table name. The table
must already exist.
- Specify a key column for the table in the Table key
field.
- Click Add to add the table node.
- Repeat these steps for each table.
- Add a join condition for the table nodes.
- Highlight the root node name and select New Element.
- In the Details box, specify Node type as
Condition.
- In the Condition field, enter the join condition using the
following syntax:.
table_name.table_column = table_name.table_column AND
table_name.table_column = table_name.table_column ...
- Click Add to add the condition.
You can now add child elements and attributes to this node.
- To add an element or attribute node:
- Click on a parent node in the field on the left to add a child element or
attribute.
If you have not selected a parent node, New is not
selectable.
- Click New Element.
- Select a node type from the Node type menu in the
Details box.
The Node type menu displays only the node types that are valid
at that point in the map. Element or
Attribute.
- Specify a node name in the Node name field.
- Click Add to add the new node.
- To map the contents of an element or attribute node to a relational
table:
- Specify a text node.
- Click the parent node.
- Click New Element.
- In the Node type field, select Text.
- Select Add to add the node.
- Add a table node.
- Select the text node you just created and click New
Element.
- In the Node type field, select Table and specify a
table name for the element.
- Click Add to add the node.
- Add a column node.
- Select the text node again and click New Element.
- In the Node type field, select Column and specify a
column name for the element.
- Specify a base data type for the column in the Type field, to
specify what type the column must be to store the untagged data.
- Click Add to add the node.
Restriction: New columns cannot be created using the
administration wizard. If you specify Column as the node type, you can
only select a column that already exists in your DB2 database.
- Optionally add a condition for the column.
- Select the text node again and click New Element.
- In the Node type field, select Condition and the
condition with the syntax:
operator LIKE|<|>|= value
- Click Add to add the node.
You can modify these nodes by selecting the node, change the fields in the
Details box, and clicking Change.
- Continue editing the RDB map or click Next to open the Specify
a DAD window.
- To remove a node:
- Click on a node in the field on the left.
- Click Remove.
- Continue editing the RDB_node map or click Next to open the
Specify a DAD window.
- Type in an output file name for the modified DAD in the File
name field of the Specify a DAD window.
- Click Finish to remove the node and return to the LaunchPad
window.
The DAD file is an XML file that you can create using any text
editor. The following steps show fragments from the samples appendix, Document access definition files. Please refer to these examples for more
comprehensive information and context.
- Open a text editor.
- Create the DAD header:
<?xml version="1.0"?>
<!DOCTYPE DAD SYSTEM "path\dad.dtd"> --> the path and file name of the DTD
for the DAD
- Insert the <DAD></DAD> tags.
- After the <DAD> tag, specify the DTD ID that associates the DAD file
with the XML document DTD.
<dtdid>path\dtd_name.dtd> --> the path and file name of the DTD
for your application
- Specify whether to validate (that is, to use a DTD to ensure that the XML
document is a valid XML document). For example:
<validation>NO</validation> --> specify YES or NO
- Use the <Xcollection> element to define the access and storage method
as XML collection. The access and storage methods define that the XML
data is stored in a collection of DB2 tables.
<Xcollection>
</Xcollection>
- Add the following prolog information:
<prolog>?xml version="1.0"?</prolog>
This exact text is required.
- Add the <doctype></doctype> tags. For example:
<doctype>! DOCTYPE Order SYSTEM "c:\dxx\samples\dtd\getstart.dtd"</doctype>
- Define the root_node using the <root_node></root_node> tags.
Inside the root_node, you specify the elements and attributes that make up the
XML document.
- After the <root_node> tag, map the elements and attributes in the XML
document to element and attribute nodes that correspond to DB2 data.
These nodes provide a path from the XML data to the DB2 data.
- Define a top level, root element_node. This element_node
contains:
- Table nodes with a join condition to specify the collection.
- Child elements
- Attributes
To specify the table nodes and condition:
- Create an RDB_node element: For example:
<RDB_node>
</RDB_node>
- Define a <table_node> for each table that contains data to be included
in the XML document. For example, if you have three tables, ORDER_TAB,
PART_TAB, and SHIP_TAB, that have column data to be in the document, create a
table node for each. For example:
<RDB_node>
<table name="ORDER_TAB">
<table name="PART_TAB">
<table name="SHIP_TAB"></RDB_node>
- Define a join condition for the tables in the collection. The
syntax is
expression = expression AND
expression = expression ...
For example:
<RDB_node>
<table name="ORDER_TAB">
<table name="PART_TAB">
<table name="SHIP_TAB">
<condition>
order_tab.order_key = part_tab.order_key AND
part_tab.part_key = ship_tab.part_key
</condition>
</RDB_node>
- Specify a primary key for each table. The primary key consists of a
single column or multiple columns, called a composite key. To specify
the primary key, add an attribute key to the table element of the
RDB_node. The following example defines a primary key for each of the
tables in the RDB_node of the root element_node Order:
<element_node name="Order">
<RDB_node>
<table name="order_tab" key="order_key"/>
<table name="part_tab" key="part_key price"/>
<table name="ship_tab" key="date mode"/>
<condition>
order_tab.order_key = part_tab.order_key AND
part_tab.part_key = ship_tab.part_key
</condition>
<RDB_node>
The information specified for decomposition is ignored when composing an
XML document.
The key attribute is required for decomposition, and when you enable a
collection because the DAD file used must support both composition and
decomposition.
- Define an <element_node> tag for each element in your XML document that
maps to a column in a DB2 table. For example:
<element_node name="name">
</element_node>
An element node can have one of the following types of elements:
- <text_node>: to specify that the element has content to a DB2
table; in this case it does not have child elements.
- <attribute_node>: to specify an attribute; attribute nodes
are defined in the next step
- child elements
The text_node contains an RDB_node to map content to a DB2 table and
column name.
RDB_nodes are used for bottom-level elements that have content to map to a
DB2 table. An RDB_node has the following child elements.
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding
element
- <condition>: optionally specifies a condition on the column
For example, you might have an XML element <Tax> for which you want to
store the untagged content in a column called TAX:
XML document:
<Tax>0.02</Tax>
In this case, you want the value 0.02 to be stored in
the column TAX.
In the DAD file, you specify an <RDB_node> to map the XML element to the
DB2 table and column.
DAD file:
<element_node name="Tax">
<text_node>
<RDB_node>
<table name="part_tab"/>
<column name="tax"/>
</RDB_node>
</text_node>
</element_node>
The <RDB_node> specifies that the value of the <Tax> element is a
text value, the data is stored in the PART_TAB table in the TAX column.
- Define an <attribute_node> for each attribute in your XML document that
maps to a column in a DB2 table. For example:
<attribute_node name="key">
</attribute_node>
The attribute_node has an RDB_node to map the attribute value to a DB2
table and column. An RDB_node has the following child elements.
- <table>: defines the table corresponding to the element
- <column>: defines the column containing the corresponding element
- <condition>: optionally specifies a condition on the column
For example, you might have an attribute key for an element
<Order>. The value of key needs to be stored in a column
PART_KEY.
XML document:
<Order key="1">
In the DAD file, create an attribute_node for key and indicate the table
where the value of 1 is to be stored.
DAD file:
<attribute_node name="key">
<RDB_node>
<table name="part_tab">
<column name="part_key"/>
<RDB_node>
</attribute_node>
- Specify the column type for the RDB_node for each attribute_node and
text_node. This ensures the correct data type for each column where the
untagged data will be stored. To specify the column types, add the
attribute type to the column element. The following example defines the
column type as an INTEGER:
<attribute_node name="key">
<RDB_node>
<table name="order_tab"/>
<column name="order_key" type="integer"/>
</RDB_node>
</attribute_node>
- Ensure that you have an ending </root_node> tag after the last
</element_node> tag.
- Ensure that you have an ending </Xcollection> tag after the
</root_node> tag.
- Ensure that you have an ending </DAD> tag after the </Xcollection>
tag.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]