Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Writing XML from a temp-table, temp-table buffers, or a ProDataSet : Omitting fields with initial values
 

Omitting fields with initial values

When a field is defined, it gets an initial value either by using the default initial value for the field's data type or from the INITIAL option in the definition statement. The following table shows the default initial values for ABL data types.
Table 25. Default initial values for ABL data types
Data type
Default initial value
BLOB
Unknown value (?)
CHARACTER
"" (empty string)
CLOB
Unknown value (?)
COM-HANDLE
Unknown value (?)
DATE
Unknown value (?)
DATETIME
Unknown value (?)
DATETIME-TZ
Unknown value (?)
DECIMAL
0
HANDLE
Unknown value (?)
INT64
0
INTEGER
0
LOGICAL
No
RAW
Zero-length sequence of bytes
RECID
Unknown value (?)
ROWID
Unknown value (?)
Omitting initial value fields from your XML can be useful if:
*Fields with initial values are not important to the business or application logic of your XML consumer
*The XML consumer knows how to recreate missing fields and populate them with initial values
To omit these fields, specify TRUE for the optional omit-initial-values argument of the WRITE-XML( ) and WRITE-XMLSCHEMA( ) methods.
The ABL extensions to XML Schema specify that an omitted field is optional and what its initial value should be. Therefore, if you generate an XML Document from ABL, the READ-XML( ) method will always correctly restore omitted fields and their initial values.
A non-ABL consumer may correctly restore omitted fields and values. For example, .NET can read an XML Schema and XML document into a dynamic ADO.NET Dataset using its ReadXmlSchema( ) and ReadXml( ) APIs, but missing elements are always interpreted as a null (unknown in ABL terms) DataColumn in the DataTable. They do recognize the initial value definition in the XML Schema when creating rows in the DataTable directly (initial value in the XML Schema gets translated to the DefaultValue property on the DataColumn), but do not with ReadXml( ).