Download XML for DB2 Information Integration nformation

Transcript
4.4.5 Inserting the DTD into the DTD_REF table
If, in the DAD file, you request validation of the XML documents that you insert
into the XML column, you need to “register” the Data Type Definition (DTD) with
XML Extender. This is done by inserting the DTD in the DTD_REF table. The
DTD_REF table is created when you enable the database for XML. You can use
the following INSERT statement (Example 4-6) to do so.
Example 4-6 Insert into DTD_REF
INSERT INTO db2xml.DTD_REF
VALUES(‘c:\xmldata\project.dtd’,
db2xml.XMLCLOBFromFile(‘c:\xmldata\project.dtd’),
0,
‘bart’,
’bart’,
‘bart’
)
Example 4-7 shows the project.dtd information that we are inserting into the
DTD_REF table that will be used to validate the XML documents when they are
inserted into the XML column later on (see 4.4.8, “Using XML Extender UDFs to
insert XML documents” on page 110).
Example 4-7 Project.dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT data (project)>
<!ELEMENT project (projectID, description, startdate, employee*)>
<!ELEMENT projectID EMPTY>
<!ELEMENT description (#PCDATA)>
<!ELEMENT startdate (#PCDATA)>
<!ATTLIST projectID id CDATA #REQUIRED>
<!ELEMENT employee (employeeID, department, firstname, lastname)>
<!ELEMENT employeeID EMPTY>
<!ELEMENT department (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ATTLIST employeeID empid CDATA #REQUIRED>
Chapter 4. Storing whole XML documents
107