Attributes to customize XML serialization / Mapping between simple 4GL and XML data types detail |
Map a 4GL Record to an XML Schema choice structure. The choice of the record's member is performed at runtime, and changes dynamically according to a mandatory member. This specific member must be of type SMALLINT or INTEGER, and have an XMLSelector attribute set. The XMLChoice attribute also supports a "nested" value that removes the surrounding XML tag.
DEFINE mychoice RECORD ATTRIBUTE(XMLChoice,XMLName="Root") val1 INTEGER ATTRIBUTE(XMLName="Val1"), val2 FLOAT ATTRIBUTE(XMLAttribute,XMLName="Val2"), sel SMALLINT ATTRIBUTE(XMLSelector), val3 STRING ATTRIBUTE(XMLName="Val3") END RECORD
<Root Val2="25.8"> <Val3>Hello world</Val3> </Root>
<Root Val2="25.8"> <Val1>148</Val1> </Root>
DEFINE myVar RECORD ATTRIBUTE(XMLName="Root") val1 INTEGER ATTRIBUTE(XMLName="Val1"), val2 FLOAT ATTRIBUTE(XMLAttribute,XMLName="Val2"), choice RECORD ATTRIBUTE(XMLChoice="nested") choice1 INTEGER ATTRIBUTE(XMLName="ChoiceOne"), choice2 FLOAT ATTRIBUTE(XMLName="ChoiceTwo"), nestedSel SMALLINT ATTRIBUTE(XMLSelector) END RECORD, val3 STRING ATTRIBUTE(XMLName="Val3") END RECORD
<Root Val2="25.8"> <Val1>148</Val1> <ChoiceOne>6584</ChoiceOne> <Val3>Hello world</Val3> </Root>
<Root Val2="25.8"> <Val1>148</Val1> <ChoiceTwo>85.8</ChoiceTwo> <Val3>Hello world</Val3> </Root>