Skip to content

First DATAMIMIC Model

Every DATAMIMIC XML descriptor has a <setup> root. The smallest useful model generates records, defines their keys, and sends them to a target.

minimal.xml
1
2
3
4
5
<setup>
    <generate name="output" count="10" target="CSV">
        <key name="counter" generator="IncrementGenerator"/>
    </generate>
</setup>

It creates ten rows in output.csv:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
counter
1
2
3
4
5
6
7
8
9
10

Split a model into reusable stages

A project can load properties, prepare source data in memory, and generate final records from separate descriptors.

conf/base.properties
1
customer_count=10
data/car.ent.csv
1
2
3
4
brand
Audi
BMW
Volvo
datamimic.xml
1
2
3
4
5
<setup>
    <include uri="conf/base.properties"/>
    <include uri="1_prepare.xml"/>
    <include uri="2_generate.xml"/>
</setup>

<include> composes the project files in document order. The preparation stage writes directly to the in-memory mem target.

1_prepare.xml
1
2
3
<setup>
    <generate name="CARS" source="data/car.ent.csv" target="mem"/>
</setup>

<generate> reads the source records and writes them to the declared target without inventing additional rows. The stored entity CARS can then be used by a later variable.

2_generate.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<setup>
    <generate name="customer" count="{customer_count}" target="JSON">
        <variable name="car" sourceEntity="CARS" source="mem" cyclic="true"/>
        <variable name="person" entity="Person(min_age=21, max_age=67, female_quota=0.5)"/>
        <variable name="company" entity="Company"/>

        <key name="id" generator="IncrementGenerator"/>
        <key name="car_brand" script="car.brand"/>
        <key name="first_name" script="person.given_name"/>
        <key name="last_name" script="person.family_name"/>
        <key name="birth_date" script="person.birthdate" converter="DateFormat('%d.%m.%Y')"/>
        <key name="email" script="'info@' + company.short_name.replace(' ', '-') + '.example'"/>
    </generate>
</setup>

This stage demonstrates the core composition pattern:

  • <generate> owns record count, source semantics, and target.
  • <variable> evaluates reusable source, entity, generator, or script values once per record.
  • <key> writes fields to the generated record.
  • cyclic="true" explicitly permits a finite source to be reused when more output records are requested.

Start with explicit values, then move shared counts and connection identifiers into properties. For nested records, use the variable-scoping guide.

Hosted Platform workflow

Creating projects, starting tasks, inspecting previews and downloading artifacts are Platform concerns. Continue with First steps in the Platform after the descriptor is valid.

Reference