IBM Books

XML Extender Administration and Programming


Appendixes


Appendix A. DTD for the DAD file

This section describes the document type declarations (DTD) for the document access definition (DAD) file. The DAD file itself is a tree-structured XML document and requires a DTD. The DTD file name is dxxdad.dtd. Figure 13 shows the DTD for the DAD file. The elements of this file are described following the figure.

Figure 13. The DTD for the document access definition (DAD)

<?xml encoding="US-ASCII"?>
 
  <!ELEMENT DAD (dtdid?, validation, (Xcolumn | Xcollection))>
  <!ELEMENT dtdid (#PCDATA)>
  <!ELEMENT validation (#PCDATA)>
  <!ELEMENT Xcolumn (table*)>
  <!ELEMENT table (column*)>
  <!ATTLIST table name CDATA #REQUIRED
                               key CDATA #IMPLIED
                               orderBy CDATA #IMPLIED>
  <!ELEMENT column EMPTY>
  <!ATTLIST column
                      name CDATA #REQUIRED
                      type CDATA #IMPLIED
                      path CDATA #IMPLIED
                       multi_occurrence CDATA #IMPLIED>
  <!ELEMENT Xcollection (SQL_stmt?, objids?, prolog, doctype, root_node)>
  <!ELEMENT SQL_stmt (#PCDATA)>
  <!ELEMENT objids (column+)>
  <!ELEMENT prolog (#PCDATA)>
  <!ELEMENT doctype (#PCDATA | RDB_node)*>
  <!ELEMENT root_node (element_node)>
  <!ELEMENT element_node (RDB_node*,
                                         attribute_node*,
                                         text_node?,
                                         element_node*,
                                         namespace_node*,
                                         process_instruction_node*,
                                         comment_node*)>
  <!ATTLIST element_node
                     name CDATA #REQUIRED
                     ID CDATA #IMPLIED
                     multi_occurrence CDATA "NO"
                     BASE_URI CDATA #IMPLIED>
  <!ELEMENT attribute_node (column | RDB_node)>
  <!ATTLIST attribute_node
                     name CDATA #REQUIRED>
  <!ELEMENT text_node (column | RDB_node)>
  <!ELEMENT RDB_node (table+, column?, condition?)>
  <!ELEMENT condition (#PCDATA)>
  <!ELEMENT comment_node (#PCDATA)>
  <!ELEMENT namespace_node (EMPTY)>
  <!ATTLIST namespace_node
                      name CDATA #IMPLIED
                     value CDATA #IMPLIED>
  <!ELEMENT process_instruction_node (#PCDATA)>

The DAD file has four major elements:

Xcolumn and Xcollection have child element and attributes that aid in the mapping of XML data to relational tables in DB2. The following list describes the major elements and their child elements and attributes. Syntax examples are taken from Figure 13.

DTDID element
Specifies the ID of the DTD stored in the DTD_REF table. DTDID points to the DTD that validates the XML documents or guides the mapping between XML collection tables and XML documents. DTDID must be specified for XML collections. For XML columns, it is optional and is only needed if you want to create side tables for indexing on elements or attributes, or validate input XML documents. DTDID must be the same as the SYSTEM ID specified in the doctype of the XML documents.

Syntax: <!ELEMENT dtdid (#PCDATA)>

validation element
Indicates whether or not the XML document is to be validated with the DTD for the DAD. If YES is specified, then the DTDID must also be specified.

Syntax: <!ELEMENT validation(#PCDATA)>

Xcolumn element
Defines the indexing scheme for an XML column. It is composed of zero or more tables.

Syntax: <!ELEMENT Xcolumn (table*)>Xcolumn has one child element, table.

table element
Defines one or more relational tables created for indexing elements or attributes of documents stored in an XML column.

Syntax:

<!ELEMENT table (column+)>
 <!ATTLIST table name CDATA #REQUIRED
							key CDATA #IMPLIED
							orderBy CDATA #IMPLIED>

The table element has one attribute:

name attribute
Specifies the name of the side table

The table element has one child element:

key attribute
The primary single key of the table

orderBy attribute
The names of the columns that determine the sequence order of multiple-occurring element text or attribute values when generating XML documents.

column element
Specifies the column of the table that contains the value of a location path of the specified type.

Syntax:

<!ATTLIST column  
                     name CDATA #REQUIRED  
                     type  CDATA #IMPLIED  
                     path  CDATA #IMPLIED  
                     multi_occurrence CDATA #IMPLIED>
The column element has the following attributes:

name attribute
Specifies the name of the column. It is the alias name of the location path which identifies an element or attribute

type attribute
Defines the data type of the column. It can be any SQL data type.

path attribute
Shows the location path of an XML element or attribute and must be the simple location path as specified in Table 3.1.a (fix link) .

multi_occurrence attribute
Specifies whether this element or attribute can occur more than once in an XML document. Values can be YES or NO.

Xcollection
Defines the mapping between XML documents and an XML collection of relational tables.

Syntax: <!ELEMENT Xcollection(SQL_stmt*, prolog, doctype, root_node)>Xcollection has the following child elements:

SQL_stmt
Specifies the SQL statement that the XML Extender uses to define the collection. Specifically, the statement selects XML data from the XML collection tables, and uses the data to generate the XML documents in the collection. The value of this element must be a valid SQL statement. It is only used for composition, and only a single SQL_stmt is allowed. For decomposition, more than one value for SQL_stmt can be specified to perform the necessary table creation and insertion.

Syntax: <!ELEMENT SQL_stmt #PCDATA >

prolog
The text for the XML prolog. The same prolog is supplied to all documents in the entire collection. The value of prolog is fixed.

Syntax: <!ELEMENT prolog #PCDATA>

doctype
Defines the text for the XML document type definition.

Syntax: <!ELEMENT doctype #PCDATA | RDB_node>doctype can be specified in one of the following ways:

  • Define an explicit value. This value is supplied to all documents in the entire collection.
  • When using decomposition, specify the child element, RDB_node, that can be mapped to and stored as column data of a table.
doctype has one child element:

RDB_node
Not yet implemented.

root_node
Defines the virtual root node. root_node must have one required child element, element_node, which can be used only once. The element_node under the root_node is actually the root_node of the XML document.

Syntax: <!ELEMENT root_node(element_node)>

element_node
Represents an XML element. It must be defined in the DTD specified for the collection. For the RDB_node mapping, the root element_node must have a RDB_node to specify all tables containing XML data for itself and all of its child nodes. It can have zero or more attribute_nodes and child element_nodes, as well as zero or one text_node. For elements other than the root element no RDB_node is needed.

Syntax:

An element_node is defined by the following child elements:

RDB_node
(Optional) Specifies tables, column, and conditions for XML data. The RDB_node for an element only needs to be defined for the RDB_node mapping. In this case, one or more tables must be specified. The column is not needed since the element content is specified by its text_node. The condition is optional, depending on the DTD and query condition.

child nodes
(Optional) An element_node can also have the following child nodes:

element_node
Represents child elements of the current XML element

attribute_node
Represents attributes of the current XML element

text_node
Represents the CDATA text of the current XML element

attribute_node
Represents an XML attribute. It is the node defining the mapping between an XML attribute and the column data in a relational table.

Syntax:

The attribute_node must have definitions for a name attribute, and either a column or a RDB_node child element. attribute_node has the following attribute:

name
The name of the attribute.

attribute_node has the following child elements:

Column
Used for the SQL mapping. The column must be specified in the SELECT clause of SQL_stmt.

RDB_node
Used for the RDB_node mapping. The node defines the mapping between this attribute and the column data in the relational table The table and column must be specified. The condition is optional.

text_node
Represents the text content of an XML element. It is the node defining the mapping between an XML element content and the column data in a relational table.

Syntax: It must be defined by a column or an RDB_node child element:

Column
Needed for the SQL mapping. In this case, the column must be in the SELECT clause of SQL_stmt.

RDB_node
Needed for the RDB_node mapping. The node defines the mapping between this text content and the column data in the relational table. The table and column must be specified. The condition is optional.


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