Skip to content

Element <nestedKey>

Purpose: Build or overlay a nested list/dict field within the current product row.

Why: Use it to build or enrich one nested dictionary or a repeated list of one shape.

Example

1
<nestedKey name="items"/>

Decision guide

Business value: Models a structured object or repeated record group without flattening business structure.

  • Use when

    • One output field contains a dictionary or repeated records with a common shape.
  • Choose another approach when

    • The value is scalar, a homogeneous scalar array, or a heterogeneous conditional list.
  • Prerequisites

    • Define the nested child fields and the intended cardinality or source.
  • Alternatives

    • Use array for homogeneous scalar collections. (See: <array>)
    • Use list for entries with different shapes or conditions. (See: <list>)

Complete examples

Assemble nested objects, conditional lists, arrays, and branches

Use this shape when one deterministic product combines nested records, heterogeneous list entries, literal arrays, and mutually exclusive fields.

structured-profile/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<setup rngSeed="42" numProcess="1">
    <generate name="profiles" count="3" target="LogExporter">
        <key name="id" generator="IncrementGenerator"/>
        <nestedKey name="address" type="dict">
            <key name="city" constant="Berlin"/>
            <key name="postal_code" constant="10115"/>
        </nestedKey>
        <list name="contacts" converter="RemoveNoneOrEmptyElement">
            <item>
                <key name="channel" constant="email"/>
                <key name="value" script="'customer-' + str(id) + '@example.test'"/>
            </item>
            <item condition="id % 2 == 0">
                <key name="channel" constant="sms"/>
                <key name="value" script="'+49-30-' + str(100000 + id)"/>
            </item>
        </list>
        <array name="roles" type="literal">
            <value constant="customer"/>
            <value constant="newsletter"/>
        </array>
        <condition>
            <if condition="id == 1">
                <key name="segment" constant="new"/>
            </if>
            <else-if condition="id == 2">
                <key name="segment" constant="active"/>
            </else-if>
            <else>
                <key name="segment" constant="loyal"/>
            </else>
        </condition>
    </generate>
</setup>

Rules and invalid combinations

cyclic requires source or script input.

Attributes: cyclic, source, script

Why: Only an existing input sequence can be repeated.

Valid combination
1
<nestedKey name="items" count="2" cyclic="true" script="[{'id': 1}]"/>
Invalid combination
1
<nestedKey name="items" count="2" cyclic="true"/>
cyclic requires count, minCount, or maxCount.

Attributes: cyclic, count, minCount, maxCount

Why: A finite count bound prevents an endlessly repeated nested input.

Valid combination
1
<nestedKey name="items" count="2" cyclic="true" script="[{'id': 1}]"/>
Invalid combination
1
<nestedKey name="items" script="[{'id': 1}]" cyclic="true"/>
script cannot be combined with source parsing attributes.

Attributes: script, source, type, separator, sourceScripted

Why: A script owns the complete nested value; source, type, separator, and sourceScripted describe a different input owner.

Valid combination
1
<nestedKey name="items" script="[{'id': 1}]"/>
Invalid combination
1
<nestedKey name="items" script="[{'id': 1}]" source="data/items.ent.csv"/>
distribution requires a list-capable source.

Attributes: distribution, source, type

Why: Distribution selects rows from a source pool; it cannot shape a scalar or source-free nested object.

Valid combination
1
<nestedKey name="items" source="mem" distribution="ordered"/>
Invalid combination
1
<nestedKey name="items" source="data/items.ent.csv" distribution="ordered"/>
Use count or minCount/maxCount, never both.

Attributes: count, minCount, maxCount

Why: Both strategies own the number of nested values.

Valid combination
1
<nestedKey name="items" type="list" count="2"/>
Invalid combination
1
<nestedKey name="items" type="list" count="2" minCount="1"/>
minCount must be less than or equal to maxCount.

Attributes: minCount, maxCount

Why: The nested repetition count is drawn from the inclusive interval between those bounds.

Valid combination
1
<nestedKey name="items" type="list" minCount="1" maxCount="3"/>
Invalid combination
1
<nestedKey name="items" type="list" minCount="3" maxCount="1"/>
A source-free list requires count, minCount, or maxCount.

Attributes: type, source, count, minCount, maxCount

Why: The list length cannot otherwise be determined.

Valid combination
1
<nestedKey name="items" type="list" count="2"/>
Invalid combination
1
<nestedKey name="items" type="list"/>
separator and sourceScripted require source.

Attributes: source, separator, sourceScripted

Why: These options modify source parsing and have no effect on script- or child-owned values.

Valid combination
1
<nestedKey name="items" source="data/items.ent.csv" separator=","/>
Invalid combination
1
<nestedKey name="items" count="1" separator=","/>
type as a memstore sourceEntity alias cannot conflict with sourceEntity.

Attributes: source, type, sourceEntity

Why: A memstore product must have one unambiguous source identity.

Valid combination
1
<nestedKey name="items" type="list" source="mem" sourceEntity="orders"/>
Invalid combination
1
<nestedKey name="items" source="mem" type="archived_orders" sourceEntity="orders"/>
I822 β€” Task NestedKey Item Not Dict

Expect current product of '{name}' is a dictionary, but got invalid datatype: '{value_type}'

Why: A value expected to be a dictionary was not a dictionary in the task configuration.

Resolution: Provide a dictionary value for the configuration.

Full rule

I192 β€” Source Reference Identifier Empty

Explicit source URI for family '{family}' requires a non-empty identifier

Why: A recognized source-family URI was declared without the identifier needed to resolve its source.

Resolution: Add the source identifier after the URI scheme and retry.

Full rule

I193 β€” Source Reference Consumer Unsupported

Explicit source family '{family}' is not supported by <{consumer}>

Why: The source family is valid, but the consuming DSL element does not implement its read contract.

Resolution: Use a source family supported by this element or move the read to generate/iterate.

Full rule

I195 β€” Source Reference Identifier Conflict

Explicit source identifier '{identifier}' conflicts with {attribute}='{configured_identifier}'

Why: Two source attributes select different identities for the same explicit source reference.

Resolution: Remove the legacy override or make it equal to the identifier in source.

Full rule

W006 β€” Memstore Dataset Selected Through type

<{element}> attribute type='{entity}' in descriptor '{descriptor}' is read as sourceEntity='{entity}'; execution continues. Use sourceEntity for dataset selection and keep type for list or dict; if you meant a container, check the spelling of type.

Why: A memstore dataset is selected through type instead of sourceEntity.

Resolution: Move the dataset name to sourceEntity; reserve type for list or dict.

Full rule

Allowed parents / Allowed children

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

Allowed children:

array, assert, condition, echo, element, execute, id, key, list, mapping, nestedKey, rule, sourceConstraints, targetConstraints, variable, while

Attributes

Show all 17 attributes

condition

Condition for nested key generation.

optional; string; Default: null.

converter

Converter for element data transformation.

optional; string; Default: null.

count

Number of nested keys to generate.

optional; string; Default: null.

cyclic

Enable or disable cyclic generation for nested keys.

optional; boolean; Default: null.

defaultValue

Default value for nested keys.

optional; string; Default: null.

distribution

Distribution type for nested key sampling.

optional; string; Default: null; Values: ordered, random, round_robin, reservoir, cumulated.

maxCount

Maximum count for nested key generation.

optional; integer; Default: null.

minCount

Minimum count for nested key generation.

optional; integer; Default: null.

name

Name of the nested key.

required; string.

script

Script for nested key generation.

optional; string; Default: null.

separator

Separator for nested key data.

optional; string; Default: null.

source

CSV/JSON project-file or memstore source for nested list/dict data; expressions resolve per row.

optional; string; Default: null.

sourceEntity

Explicit memstore product to read (overrides the nested-key name fallback).

optional; string; Default: null.

sourceScripted

Enable or disable scripted sources.

optional; boolean; Default: null.

type

Type of the nested key.

optional; string; Default: null; Values: list, dict.

variablePrefix

Prefix before field names inside nested selectors.

optional; string; Default: null.

variableSuffix

Suffix after field names inside nested selectors.

optional; string; Default: null.