Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Reading XML Schema into a temp-table, temp-table buffer, or ProDataSet : Verifying a static temp-table against XML Schema
 

Verifying a static temp-table against XML Schema

This code sample demonstrates schema verification with a static temp-table:
/* pi-tfx-read-2.p */
/* Verifies XML Schema against a static temp-table. */

{pi-tfx-parameterVarDefs.i}

DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO.
DEFINE TEMP-TABLE ttCustomer NO-UNDO
  FIELD CustNum LIKE Customer.CustNum
  FIELD Name    LIKE Customer.Name FORMAT "X(30)".

ASSIGN
  cSourceType             = "FILE"
  cFile                   = "ttCustomer.xsd"
  lOverrideDefaultMapping = ?
  cFieldTypeMapping       = ?
  cVerifySchemaMode       = "STRICT".

DISPLAY "Reading XML Schema..." SKIP.

lReturn = TEMP-TABLE ttCustomer:READ-XMLSCHEMA(cSourceType, cFile,
  lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode).
IF lReturn THEN
  DISPLAY "Success: Temp-table definition verified against XML Schema.".
END.
As written, this code sample fails with the following error messages:
Because the verification mode is "STRICT", the presence of more fields in the XML Schema than are actually defined for the temp-table causes the method to fail. The definition and the XML Schema are not an exact match. Change the verification mode to "LOOSE", and the code completes successfully because the temp-table definition is a partial match for the XML Schema.