Bỏ qua

Element <id>

Warning

The current page still doesn't have a translation for this language.

But you can help translating it: Contributing.

Purpose: Define one generated, copied, converted, or scripted field in a product.

Why: Use this key alias to communicate that the generated field identifies the record.

Example

1
<key name="customer_id" generator="IncrementGenerator"/>

Decision guide

Business value: Communicates record identity explicitly while retaining the complete key-generation contract.

  • Use when

    • A field uniquely or stably identifies the current product record.
  • Choose another approach when

    • The field is an ordinary measure, label, or transient calculation.
  • Prerequisites

    • Choose a generator, source, or script that satisfies the intended identity scope.
  • Alternatives

    • Use key for visible fields without identifier semantics. (See: <key>)

Complete examples

Mark record identity explicitly

Use id when a key represents record identity; it retains the full key generation contract.

id-alias/datamimic.xml
1
2
3
4
5
6
<setup>
    <generate name="customers" count="3" target="LogExporter">
        <id name="customer_id" generator="IncrementGenerator"/>
        <key name="status" constant="active"/>
    </generate>
</setup>

Rules and invalid combinations

A key requires one value-generation mode.

Attributes: type, source, values, script, generator, constant, pattern, string

Why: A field without a type, source, value pool, script, generator, constant, pattern, or string template cannot produce a value.

Valid combination
1
<key name="status" constant="active"/>
Invalid combination
1
<key name="status"/>
Choose exactly one explicit key generation mode.

Attributes: source, values, script, generator, constant, pattern, string

Why: Combining source, values, script, generator, constant, pattern, or string would make ownership of the field value ambiguous.

Valid combination
1
<key name="status" constant="active"/>
Invalid combination
1
<key name="status" constant="active" string="${status}"/>
weights requires an inline values pool.

Attributes: weights, values

Why: Each weight biases the corresponding values entry and has no meaning without that pool.

Valid combination
1
<key name="tier" values="'standard','premium'" weights="3,1"/>
Invalid combination
1
<key name="tier" type="string" weights="3,1"/>
unique on a key requires an inline values pool.

Attributes: unique, values

Why: Key uniqueness is sampling without replacement from explicitly listed values; generators do not expose a finite pool here.

Valid combination
1
<key name="code" values="'A','B'" unique="true"/>
Invalid combination
1
<key name="code" generator="IncrementGenerator" unique="true"/>
unique cannot be combined with weights.

Attributes: unique, weights

Why: Unique sampling is uniform without replacement; weights describe biased draws with replacement.

Valid combination
1
<key name="code" values="'A','B'" unique="true"/>
Invalid combination
1
<key name="code" values="'A','B'" weights="1,2" unique="true"/>
Source parsing options require source.

Attributes: source, selector, separator

Why: selector, separator, and source-dependent options only modify a source read.

Valid combination
1
<key name="status" source="data/status.ent.csv" separator=","/>
Invalid combination
1
<key name="status" type="string" separator=","/>
A key distribution requires an int, float, or decimal range.

Attributes: distribution, type, min, max

Why: The key-level distribution shapes a numeric grid and is different from source-row distribution.

Valid combination
1
<key name="score" type="int" min="1" max="10" distribution="step"/>
Invalid combination
1
<key name="score" type="string" distribution="step"/>
Decimal bounds must be finite, ordered, and contain a value on the granularity grid.

Attributes: type, min, max, granularity

Why: Exact decimal generation cannot round a sampled value outside its declared bounds.

Valid combination
1
<key name="amount" type="decimal" min="0.10" max="1.00"/>
Invalid combination
1
<key name="amount" type="decimal" min="0.11" max="0.12" granularity="0.10"/>
outDateFormat produces a string and rejects a non-string type.

Attributes: outDateFormat, type

Why: Formatting is the final presentation step; downstream expressions no longer receive the raw temporal value.

Valid combination
1
<key name="created" constant="2026-01-02" outDateFormat="%d.%m.%Y"/>
Invalid combination
1
<key name="created" type="int" constant="2026-01-02" outDateFormat="%d.%m.%Y"/>
Integer granularity must be a whole number.

Attributes: type, granularity

Why: A fractional step cannot produce an integer grid without silent truncation.

Valid combination
1
<key name="score" type="int" granularity="2"/>
Invalid combination
1
<key name="score" type="int" granularity="0.5"/>
defaultValue requires script.

Attributes: defaultValue, script

Why: The fallback is evaluated only when the scripted value is absent or its condition suppresses generation.

Valid combination
1
<key name="nickname" script="None" defaultValue="'unknown'"/>
Invalid combination
1
<key name="nickname" constant="unknown" defaultValue="'fallback'"/>
nullQuota must be between 0 and 1.

Attributes: nullQuota

Why: The value represents a probability: 0 never emits null and 1 always emits null.

Valid combination
1
<key name="middle_name" type="string" nullQuota="0.5"/>
Invalid combination
1
<key name="middle_name" type="string" nullQuota="1.1"/>
min, max, and granularity need type int, float, or decimal as the only value source; decimal granularity also rounds any value source.

Attributes: type, min, max, granularity, source, values, script, generator, constant, pattern, string

Why: Only the type-driven value path reads the range. Another value source, a missing type, or a non-numeric type would ignore it without a message; a generator takes its range in its own arguments. Decimal granularity rounds the value of every value source.

Valid combination
1
<key name="amount" type="int" min="100" max="500"/>
Invalid combination
1
<key name="amount" type="int" generator="IntegerGenerator" min="100" max="500"/>

Allowed parents / Allowed children

Allowed parents: comment, else, else-if, generate, if, item, iterate, nestedKey, while

Allowed children:

comment, element

Attributes

Show all 29 attributes

condition

Condition for key data generation.

optional; string; Default: null.

constant

Constant value for key data.

optional; string; Default: null.

converter

Converter for key data transformation.

optional; string; Default: null.

database

Database client id when source equals 'database'.

optional; string; Default: null.

defaultValue

Default value for the key.

optional; string; Default: null.

distribution

Sampling distribution / sequence for ranged numeric key.

optional; string; Default: null; Values: uniform, cumulated, step, increment, randomWalk, shuffle, wedge, bitreverse, fibonacci, padovan.

generator

Predefined generators for key data generation.

optional; string; Default: null.

granularity

Step width of numeric grid; defaults 1 for int, 0.1 for float, and lexical scale for decimal. Decimal values use exact zero-anchored multiples; unbounded decimal sampling uses [0, 100]. On int, granularity must be whole. Applies only when type is int, float or decimal and is the only value source; on decimal it also rounds the value of any other value source.

optional; string; Default: null.

inDateFormat

Input date format for key data.

optional; string; Default: null.

max

Maximum value of the random range. Applies only when type is int, float or decimal and is the only value source.

optional; number; Default: null.

maxLength

Maximum length for binary payload generation.

optional; integer; Default: null.

mimeType

Optional MIME signature for binary payload generation.

optional; string; Default: null.

min

Minimum value of the random range. Applies only when type is int, float or decimal and is the only value source.

optional; number; Default: null.

minLength

Minimum length for binary payload generation.

optional; integer; Default: null.

name

Name of the key.

required; string.

nullQuota

Null quota for key data generation.

optional; number; Default: null.

outDateFormat

Output date format for key data.

optional; string; Default: null.

pattern

Pattern for key data generation.

optional; string; Default: null.

script

Script for key data generation.

optional; string; Default: null.

selector

Selector for key data generation.

optional; string; Default: null.

separator

Separator for key data.

optional; string; Default: null.

source

Source of data for the key.

optional; string; Default: null.

string

String for the variable data generation.

optional; string; Default: null.

type

Data type of the key.

optional; string; Default: null; Values: string, int, integer, float, decimal, bool, binary.

unique

Emit each value at most once (distinct picks from values, no replacement).

optional; boolean; Default: null.

values

Comma-separated list of values for the key.

optional; string; Default: null.

variablePrefix

Prefix before field's name for string in key generation.

optional; string; Default: null.

variableSuffix

Suffix after field's name for string in key generation.

optional; string; Default: null.

weights

Comma-separated relative weights, one per values entry, for weighted random selection.

optional; string; Default: null.