Use the XML schema to validate XML column data.
To use the XML schema for validation:
- In the Data Project Explorer, right-click the SQL Scripts folder,
and select . The New SQL Statement wizard opens.
- Click Next.
- In the Statement name field, type createEmployeeTable.
- Select SQL editor.
- In the Statement template field, select None.
- Click Finish. The SQL
editor opens.
- In the SQL editor, create a table that contains employee information
as an XML value. Copy and paste the following SQL statement into the editor:
CREATE TABLE XMLSCHEMANAME.EMPLOYEETABLE (employee XML NOT NULL)
- From the menu bar, select .
- In the SQL editor, right-click and select Run SQL. You can view the results in the Data Output view.
- In the Database Explorer view, expand the XMLDB connection, and
navigate to theXMLSCHEMANAME.EMPLOYEETABLE table. If
you do not see the XMLSCHEMANAME.EMPLOYEETABLE table, right-click
theXMLSCHEMANAME.EMPLOYEETABLE folder and select Refresh.
- Right-click on the XMLSCHEMANAME.EMPLOYEETABLE table,
and select . The Table editor opens.
- Click the ellipsis [...] button. The XML editor
opens.
- Copy and paste the following XML into the XML editor:
<employee xmlns="http://www.ibm.com/tutorialemployee" id="100">
<lastName>Smith</lastName>
<firstName>Jane</firstName>
<hireDate>2005-12-01</hireDate>
</employee>
- Select Validate XML document.
- Click Next.
- Select Specify a registered XML schema,
and then select MyRelationalSchema.MyXMLSchema.
- Click Finish.
- From the menu bar, select .
You can view the messages and results in the Data Output view.