XML record format
The XML record format used by FICO Application Studio has the following structure: The top-level element is InputRecordList (for inputs) or ResultRecordList (for results), which always contains a single InputRecord or ResultRecord. Data comes in the form of scalars or arrays.
- Scalars are represented as values enclosed in a named element, as shown in the example below.
- Arrays are represented as a 'table' comprised of a named element which contains multiple 'rec' (_rec) elements that represent rows of the table. Each table row contains multiple elements representing individual cells. The following example has a table named 'Channels' with three columns: 'Channel', 'Cost', and 'Capacity'.
<?xml version="1.0"?> <InputRecordList xmlns="http://www.fico.com/input" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <InputRecord> <MyScalarValue>7.5</MyScalarValue> <AnotherScalar>a string value</AnotherScalar> <Channels> <Channels_rec> <Channel>1</Channel> <Cost>0.5</Cost> <Capacity>100</Capacity> </Channels_rec> <Channels_rec> <Channel>2</Channel> <Cost>1.2</Cost> <Capacity>50</Capacity> </Channels_rec> <Channels_rec> <Channel>3</Channel> <Cost>3</Cost> <Capacity>40</Capacity> </Channels_rec> </Channels> </InputRecord> </InputRecordList>
In a Mosel model, data input from such XML files needs to be preceeded by a call to appsxmlimport to register the inputs:
declarations myScalar: real ChannelCost,ChannelCapacity: array(CHANNELS: range) of real end-declarations appsxmlimport initialisations from appsxmlin("MyScalarValue") myScalar as "[](MyScalarValue)" end-initialisations initialisations from appsxmlin("Channels") [ChannelCost,ChannelCapacity] as "[](Channel,Cost,Capacity) end-initialisations
Inversely, data output from a Mosel model needs to be terminated with a call to appsxmlexport to generate the XML format data and the corresponding XSD schema definition from the output data:
declarations ResultCost,ResultCapacity: array(CHANNELS: range) of real end-declarations initialisations appsxmlout("ResultChannels") [ChannelCost,ChannelCapacity] as "[](ResultChannel,ResultCost,ResultCapacity)" end-initialisations appsxmlexport
Please note that array data needs to be specified in sparse format, that is, all indices are specified along with the value columns.