Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Using XML Schema : Examples of additional XML support : XML schema with no explicit field definition for a parent table
XML schema with no explicit field definition for a parent table
The following example demonstrates the functionality of creating a DATASET definition from an XML schema where a parent temp-table contains no field definitions. The following XML schema is structured as a ProDataSet:
<schema xmlns=""
<element name="Air_FlightInfo">
<element name="generalFlightInfo">
<element name="flightDate" minOccurs="0">
<element name="departureDate" type="xsd:date"/>
<element name="departureTime" type="xsd:string"/>
<element name="arrivalDate" type="xsd:date"/>
<element name="arrivalTime" type="xsd:string"/>
<element name="flightIdentification" minOccurs="0">
<element name="flightNumber" type="xsd:string"/>
<element name="operationalSuffix" type="xsd:string"/>
This XML schema is structured like a ProDataSet, Air_FlightInfo containing three temp-tables:
*generalFlightInfo, with no fields defined
*flightDate nested with generalFlightInfo, with 4 fields: departureDate, departureTime, arrivalDate, and arrivalTime
*flightIdentification nested within generalFlightInfo, with two fields: flightNumber, and operationalSuffix
The following is the static ProData definition for the XML schema:
     FIELD generalFlightInfo_field AS INTEGER XML-NODE-TYPE "Hidden".

     FIELD departureDate AS DATE
     FIELD departureTime AS CHARACTER
     FIELD arrivalDate AS DATE
     FIELD arrivalTime AS CHARACTER
     FIELD generalFlightInfo_id AS RECID XML-NODE-TYPE "Hidden".

DEFINE TEMP-TABLE flightIdentification NO-UNDO
     FIELD flightNumber AS CHARACTER
     FIELD operationalSuffix AS CHARACTER
     FIELD generalFlightInfo_id AS RECID XML-NODE-TYPE "Hidden".

    FOR generalFlightInfo, flightDate, flightIdentification
    PARENT-ID-RELATION Relation1 FOR generalFlightInfo, flightDate
        PARENT-ID-FIELD generalFlightInfo_id
PARENT-ID-RELATION Relation2 FOR generalFlightInfo, flightIdentification
        PARENT-ID-FIELD generalFlightInfo_id.
The top-level table, generalFlightInfo, does not have fields defined. Therefore, bproxsdto4gl and READ-XMLSCHEMA( ) adds an integer <tablename_field>, in this case generalFlightInfo_field, to the generalFlightInfo temp-table definition. READ-XML() or READ-XMLSCHEMA() methods on the XML Schema will create the dynamic equivalent of this static definition.
The following is the ABL code required to create the data for the Air_FlightInfo dataset:
CREATE generalFlightInfo.

CREATE flightDate.
ASSIGN flightDate.departureDate = 12/2/2010
       flightDate.departureTime = "13:15"
       flightDate.arrivalDate = 12/2/2010
       flightDate.arrivalTime = "16:45"
       flightDate.generalFlightInfo_id = RECID(generalFlightInfo).

CREATE flightIdentification.
ASSIGN flightIdentification.flightNumber = "1024"
       flightIdentification.operationalSuffix = "ABC"
       flightIdentification.generalFlightInfo_id = RECID(generalFlightInfo).

DATASET Air_FlightInfo:WRITE-XML("file", "FlightInfo.xml", TRUE).
The following is the XML output:
<?xml version="1.0" encoding="UTF-8"?>