< Previous | Next >

Using the XML schema to validate XML column data

Use the XML schema to validate XML column data.

To use the XML schema for validation:

  1. In the Data Project Explorer, right-click the SQL Scripts folder, and select New > SQL Statement . The New SQL Statement wizard opens.
  2. Click Next.
  3. In the Statement name field, type createEmployeeTable.
  4. Select SQL editor.
  5. In the Statement template field, select None.
  6. Click Finish. The SQL editor opens.
  7. 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)
  8. From the menu bar, select File > Save .
  9. In the SQL editor, right-click and select Run SQL. You can view the results in the Data Output view.
  10. 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.
  11. Right-click on the XMLSCHEMANAME.EMPLOYEETABLE table, and select Data > Edit . The Table editor opens.
  12. Click the ellipsis [...] button. The XML editor opens.
  13. 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>
  14. Select Validate XML document.
  15. Click Next.
  16. Select Specify a registered XML schema, and then select MyRelationalSchema.MyXMLSchema.
  17. Click Finish.
  18. From the menu bar, select File > Save.
You can view the messages and results in the Data Output view.
< Previous | Next >