Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Using XML Schema : Inferring data-relations from nested XML and XML Schema

Inferring data-relations from nested XML and XML Schema

ABL supports the mapping of complex XML and XML Schema to a ProDataSet definition. When temp-tables within the XML are nested, a relationship is required between the parent table and its nested child in order to preserve the round-trip of the schema and data serialization.
When there is no explicit relationship defined in the XML Schema, or no implicit relationship can be found based a matching field in the parent and nested child tables, ABL provides a PARENT-ID-RELATION for the ProDataSet. A PARENT-ID-RELATION relates the parent and child based on the RECID of the parent record.
The PARENT-ID-RELATION allows ABL to expand the set of XML formats that can map to a ProDataSet. This expanded support includes the following:
*READ-XML( ), READ-XMLSCHEMA( ), and the bproxsdto4gl utility will create a PARENT-ID-RELATION when reading XML or XML Schema if a DATA-RELATION cannot be used to represent the nested XML. These methods will also add a RECID field to the child table with XML-NODE-TYPE "HIDDEN" to hold the RECID of the parent record. When creating records, READ-XML( ) will automatically populate the added field in the child table with the RECID of the parent record.
*WRITE-XML( ) and WRITE-XMLSCHEMA( ) recognize the PARENT-ID-RELATION and serialize the data and schema correctly.
*The PARENT-ID-RELATION phrase is available on the DEFINE DATASET statement, and the ADD-PARENT-ID-RELATION method is available on a dynamic ProDataSet object.
*PARENT-FIELDS-BEFORE and PARENT-FIELDS-AFTER options are available on a PARENT-ID-RELATION, which specify which parent fields are to be serialized before and after the nested child records.
*XML-NODE-TYPE and SERIALIZE-HIDDEN are available at the ProDataSet level so that a ProDataSet can be serialized with the top-level temp-table as the root node of the XML document.