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:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <element name="Air_FlightInfo">
    <complexType>
      <sequence>
        <element name="generalFlightInfo">
          <complexType>
            <sequence>
              <element name="flightDate" minOccurs="0">
                <complexType>
                  <sequence>
                    <element name="departureDate" type="xsd:date" />
                    <element name="departureTime" type="xsd:string" />
                    <element name="arrivalDate" type="xsd:date" />
                    <element name="arrivalTime" type="xsd:string" />
                  </sequence>
                </complexType>
              </element>
              <element name="flightIdentification" minOccurs="0">
                <complexType>
                  <sequence>
                    <element name="flightNumber" type="xsd:string" />
                    <element name="operationalSuffix" type="xsd:string" />
                  </sequence>
                </complexType>
              </element>
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>
  </element>
</schema>

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:

DEFINE TEMP-TABLE generalFlightInfo NO-UNDO
     FIELD generalFlightInfo_field AS INTEGER XML-NODE-TYPE "Hidden".

DEFINE TEMP-TABLE flightDate NO-UNDO
     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".

DEFINE DATASET Air_FlightInfo
    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"?>
<Air_FlightInfo>
	<generalFlightInfo>
		<flightDate>
			<departureDate>2010-12-02</departureDate>
			<departureTime>13:15</departureTime>
			<arrivalDate>2010-12-02</arrivalDate>
			<arrivalTime>16:45</arrivalTime>
		</flightDate>
		<flightIdentification>
			<flightNumber>1024</flightNumber>
			<operationalSuffix>ABC</operationalSuffix>
		</flightIdentification>
	</generalFlightInfo>
</Air_FlightInfo>