Registering XML Schema to IBM DB2 pureXML

Target Audience: DBA, DB Developers
What you should know: XML, XML Schema, Understanding of IBM DB2 pureXML

DB2 is unrivaled in its ability to manage both relational and XML data, enabling strong runtime performance and high levels of development time and cost savings. By integrating XML data intact into a relational database structure, users can take full advantage of DB2’s relational data management features.

XML Document Validation

Using your file system, XML documents can be validated using Document Type Definition (DTD) or XML Schema Document (XSD). The validation is done using the namespace declaration in the XML document.

XML Column Validation

XML (column) validation is the process of determining whether the structure, content, and data types of an XML (column) document are valid according to an XML schema.

When you plan to make use of pureXML features you should consider XML document validation when you insert into XML columns. You can register schema document (XSD) to DB2 and that can be identified using schema id. For example, the following XML schema document contains definitions for element called isbn:

<?xml version="1.0" ?>
<schema xmlns="" targetNamespace="" xmlns:tns="">
<complexType name="isbnType">
<element name="bktitle" type="string"/>
<element name="author" type"string" />
<element name="isbn" type="tns:isbnType" />

Suppose, the above file is located in /home/theuser/ibm/schema_for_isbn.xsd then, the CLP command for registering above schema is as follows
REGISTER XMLSCHEMA 'schema_for_isbn.xsd' FROM 'file:////home/theuser/ibm/schema_for_isbn.xsd' AS DB2INST1.LIBRARY_BOOK_SCHEMA;
Then issue the following command to validate the XML schema and activate it:

Managing XML Schema in IBM DB2

Permanent link to this article:

Leave a Reply

Your email address will not be published.