Example—Extending the Input Data Model

This is the simplest case: enabling a module to add new fields and set their values but not to remove or change the values of existing fields.

Assume that the specification file contains the following instructions in the node definition:

<OutputDataModel mode="extend">
     <AddField name=”field1” storage=”string” ... />
     <AddField name=”field2” storage=”real” ... />
     ...
</OutputDataModel>

Here, the output data model is defined as comprising all of the fields in the input data model plus the two extra fields specified in the OutputDataModel element. Thus, the output data model consists of five fields.

The clemext_peer_getDataModel function returns information only on the added fields, for example:

<DataModel>
     <Fields>
          <Field name=”field1” storage=”string” ... />
          <Field name=”field2” storage=”real” ... />
     <Fields>
</DataModel>

The returned information must match the type and number values (but not the name) of the <AddField> elements in the specification file.

A module can use the callback function clemext_node_getOutputDataModel to get the details of the fields that IBM® SPSS® Modeler expects will be added. This information can be passed straight back to IBM SPSS Modeler in response to a call to clemext_peer_getDataModel. Doing so is useful in situations where the specification file logic for creating and naming output fields is complicated.

The module provides the new values for each output record when IBM SPSS Modeler calls clemext_peer_getRecordValue. The field indices for the new fields start after the last index for the input fields. In this example, the input data model contains three fields (at index positions 0, 1, and 2), so the two output fields are assigned field indices 3 and 4. IBM SPSS Modeler will not call clemext_peer_getRecordValue with field indices corresponding to the input fields because the module cannot change these fields.