PreviousNextIndex

READ-XMLSCHEMA( ) method

Reads XML Schema from an XML document and uses that schema to either create a schema for a ProDataSet or temp-table object, or verify existing schema in a ProDataSet, temp-table, or temp-table buffer object. The XML document must be an XML Schema written in the XML Schema Definition (XSD) language in the 2001 XML Schema namespace (http://www.w3.org/2001/XMLSchema).

Return type: LOGICAL

Applies to: Buffer object handle, ProDataSet object handle, Temp-table object handle

Syntax
READ-XMLSCHEMA ( source-type, { file | memptr | handle | longchar }, 
override-default-mapping [, field-type-mapping [, verify-schema-mode ] ] ) 

source-type
file
memptr
handle
longchar
override-default-mapping
field-type-mapping
field-name
data-type
verify-schema-mode

If the ProDataSet or temp-table object does not have a schema (that is, the object is dynamic and in the CLEAR state), the AVM creates the schema from the XML Schema defined in the XML Schema document.

If the ProDataSet or temp-table object already has a schema (that is, the object is static, or the temp-tables are in the PREPARED state), the AVM verifies the XML Schema defined in the XML Schema document against the object’s schema.

If a dynamic temp-table is not in the PREPARED or CLEAR state, the method generates an error and returns FALSE.

For more information about creating schema from XML Schema or verifying XML Schema, see OpenEdge Development: Working with XML.

You cannot create schema for a temp-table buffer or a database buffer.

The following code example verifies the schema in a static ProDataSet object, in STRICT mode, using the schema defined in the specified XML Schema file:

DEFINE VARIABLE lRetOK                  AS LOGICAL   NO-UNDO. 
DEFINE VARIABLE cSourceType             AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cFile                   AS CHARACTER NO-UNDO. 
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL   NO-UNDO. 
DEFINE VARIABLE cFieldTypeMapping       AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cVerifySchemaMode       AS CHARACTER NO-UNDO. 
DEFINE TEMP-TABLE ttCustomer LIKE Customer NO-UNDO. 
DEFINE TEMP-TABLE ttOrder    LIKE Order    NO-UNDO. 
DEFINE TEMP-TABLE ttInvoive  LIKE Invoice  NO-UNDO. 
DEFINE DATASET DSET FOR ttCustomer, ttOrder, ttInvoice 
  DATA-RELATION CustOrd FOR ttCustomer,  
    ttOrd RELATION-FIELDS(CustNum,CustNum) NESTED 
  DATA-RELATION OrdInv FOR ttOrder,  
    ttInv RELATION-FIELDS(OrderNum,OrderNum) NESTED. 
ASSIGN 
  cSourceType             = "file" 
  cFile                   = "cust-ord-inv.xsd" 
  lOverrideDefaultMapping = FALSE 
  cFieldTypeMapping       = ? 
  cVerifySchemaMode       = "strict"/ 
lRetOK = DATASET DSET:READ-XMLSCHEMA (cSourceType, cFile, 
  lOverrideDefaultMapping, cFieldTypeMapping,cVerifySchemaMode). 

The following code example creates a dynamic temp-table object, creates the object’s schema from the specified XML Schema file, and overrides the default data type mapping of one field:

DEFINE VARIABLE lRetOK                  AS LOGICAL   NO-UNDO. 
DEFINE VARIABLE cSourceType             AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cFile                   AS CHARACTER NO-UNDO. 
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL   NO-UNDO. 
DEFINE VARIABLE cFieldTypeMapping       AS CHARACTER NO-UNDO. 
DEFINE VARIABLE cVerifySchemaMode       AS CHARACTER NO-UNDO. 
DEFINE VARIABLE hTable                  AS HANDLE    NO-UNDO. 
CREATE TEMP-TABLE hTable. 
ASSIGN 
  cSourceType             = "file" 
  cFile                   = "ttcust.xsd" 
  lOverrideDefaultMapping = FALSE 
  cFieldTypeMapping       = "address2,CLOB" 
  cVerifySchemaMode       = ?. 
lRetOK = hTable:READ-XMLSCHEMA (cSourceType, cFile, lOverrideDefaultMapping, 
  cFieldTypeMapping,cVerifySchemaMode). 

See also: IS-XML attribute, READ-XML( ) method, WEB-CONTEXT system handle, WRITE-XML( ) method, WRITE-XMLSCHEMA( ) method, X-document object handle, X-noderef object handle


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex