Registering XML Schema in DB2 9 Using Visual Studio 2005 - Page 2

November 9, 2006

Registering an XML Schema Definition in DB2 9 using Visual Studio 2005

In order to take full advantage of the powerful capabilities of the pureXML feature in DB2 9, you need to register your XSDs in the DB2 9 XSR. Once an XSD is registered in the XSR, you can optionally validate all incoming XML documents with the XSD document or code business logic in the database to perform validation.

To register the Customer XSD that you created in the last article of this series, perform the following steps:

1.  Right-click XML Schema Repository and select Register XML Schema:

The XSD Registration designer opens:

2.  Click the ellipsis () and navigate to the path where you saved the Customer XSD document in the previous article, and click Open.

When you do this, the XSR name field and the associated dependency on any XML Schemas within the selected XSD document (in this case, the CanadianAddress.xsd, which defines the complex CanadianAddress data type) are automatically filled in for you as shown below:

3.  Press Ctrl+S to register the schema when you have focus on the XSD designer. If you’re registering this XSD document in the SAMPLE database created with the options outlined at the start of this article, you should receive the following error:

If you created the SAMPLE database with the XML option, then you will receive this error because an XSD document with the same name is registered in this database as part of the SAMPLE database creation process:

I included this error in this article to illustrate that fact that you can only have a single instance of an XML Schema name for a particular schema in the database, although different names can contain versions of the same schema.

One of the key capabilities of the XSR support in DB2 9 is the ability to support evolving schemas. Let’s assume that the schema we created in the previous article was an evolution of a schema that already existed in the database. In this case, you could change the registration of the schema by calling it by a different name and mapping it to the underlying file name, as shown below:

Once you have registered your XSD document it should show up in the Server Explorer window, at which time you can perform multiple actions on it from the Visual Studio IDE:

Wrapping it Up...

In this article, I showed you how to register an XML Schema Definition document in the DB2 9 XML Schema Repository without leaving Visual Studio 2005. This demonstrates the rich functionality provided by the IBM Database add-ins for Visual Studio 2005. This free download keeps productivity high in a .NET environment.

Of course, there are many ways to register schemas in DB2 9. For example, you could use the new DB2 9 Developer Workbench (an Eclipse-based development tool):


Or, you can use the following syntax in the command line processor (CLP):

In my next article, I’ll show you how to create a table that uses an XML column and an index specifically designed for searching the XML column using an XML pattern expression – all without ever leaving your Visual Studio 2005 IDE.

The Network for Technology Professionals


About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers