XMLStructure

The XMLStructure simple property identifies the potential structure of the XML elements that are represented by fields in a Record part. This topic contains examples that describe what happens when you transfer record data to an XML string. The relationships also apply in the opposite direction, when the EGL runtime code validates the transfer of an XML string to an input record.
The supported values for XMLStructure are as follows:
sequence (the default)
On output, the XML string must include every field in the Record part, in the order in which the Record fields are listed. The following Record part and XML string are related:
Record Employee {XMLStructure = XMLStructureKind.sequence}
   EmpNo INT;
   LastName STRING;
end

<Employee>
   <EmpNo>10</EmpNo>
   <LastName>Smith</LastName> 
</Employee>
choice
On output, the XML string must include only one subordinate element that corresponds to a record field. For example, consider the following Record part:
Record Employee{XMLStructure = XMLStructureKind.choice}
   ImmigrationStatus STRING?; 
   YearsOfCitizenship INT?;
end
Either of the following XML strings is valid:
<Employee>
   <ImmigrationStatus>A1</ImmigrationStatus>
</Employee>
<Employee>
   <YearsOfCitizenship>20</YearsOfCitizenship>
</Employee>

In this case, the XML string cannot include both kinds of elements.

If a record has the XMLStructure value "choice", each field must be nullable, as is indicated by the question marks in the example. The value of one field must be non-null, and the value of only one field can be non-null. If all of the fields in the input record are null or if more than one field is non-null, the XMLLib.convertToXML function issues a RuntimeException.

simpleContent
On output, the simple content that is transferred to an XML string is the value of a field in a superior record (a field written as an XML element) and a set of attributes. For example, the following boldface Record part and XML content are related:
Record Employee{XMLStructure = XMLStructureKind.sequence}
   EmpNo EmpNumber;
   LastName STRING;
end

Record EmpNumber {XMLStructure = XMLStructureKind.simpleContent}
  	department STRING {@XMLAttribute{}};
  	value INT; // any field name is acceptable here
end
<Employee>
   <EmpNo department="Sales">10</EmpNo>
   <LastName>Smith</LastName> 
</Employee>

The subordinate record, EmpNumber, can include any number of fields that are of type STRING and that have the @XMLAttribute property. The property indicates that a given field represents an attribute. The same subordinate record might have a field that lacks the @XMLAttribute property; that non-attribute field, if any, holds the value of the related element. The non-attribute field can have any name.

unordered
The XML string includes the specified elements in any order. The following Record part describes either of the subsequent XML strings:
Record Employee {XMLStructure = XMLStructureKind.unordered}
   EmpNo INT;
   LastName STRING;
end

<Employee>
   <LastName>Jones</LastName> 
   <EmpNo>20</EmpNo>
</Employee>

<Employee>
   <EmpNo>20</EmpNo>
   <LastName>Jones</LastName> 
</Employee>

Those values constitute the xmlStructureKind enumeration.


Feedback