Skip to content

Expression Evaluation and Lifetime

DATAMIMIC distinguishes literal attribute values from two full-value expression forms. The braces are part of attribute resolution; a regular script="..." already contains an expression and does not need another pair of braces.

Form Evaluation Use it when
value Literal The value is fixed text or a fixed number.
{expression} Cached in the active record iteration Repeated reads in one iteration must observe one result.
{{expression}} Fresh on every access A supported per-record attribute deliberately needs reevaluation.

Expressions occupy the complete attribute value. Build a path in a variable and reference it as {path}; interpolation such as data/{version}/customers.csv is not part of this contract.

Setup-time and per-record boundaries

Connection/source selection and output-routing setup attributes must be resolved before generation starts. They accept a literal or {expression} evaluated in the root setup context. A dynamic {{expression}} in such an attribute fails with catalog rule I870; DATAMIMIC does not silently freeze a value that was declared dynamic.

Attributes with a documented per-record lifetime, such as nested count, may use both forms. targetEntity also supports both forms when every selected target supports per-record routing; other targets reject that combination. The following descriptor resolves root_count and destination from setup variables. The nested count is evaluated in each parent record, so batch 1 produces one event and batch 2 produces two events.

expression-lifetime.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<setup numProcess="1">
    <variable name="destination" constant="LogExporter"/>
    <variable name="root_count" constant="2"/>
    <generate name="batches" count="{root_count}" target="">
        <key name="batch_id" generator="IncrementGenerator"/>
        <generate name="events" count="{{batch_id}}" target="{destination}">
            <key name="batch_id" script="this.parent.batch_id"/>
            <key name="event_id" generator="IncrementGenerator"/>
        </generate>
    </generate>
</setup>

Prefer {expression} unless reevaluation is part of the intended behavior. It makes the lifetime explicit and avoids repeated work inside one record iteration. Setup-time expressions always read the root setup context; nested record fields are not available there.