Zum Inhalt

Element <nestedKey>

Zweck: Erstellt oder ergänzt ein verschachteltes Listen- oder Dictionary-Feld im aktuellen Produktdatensatz.

Warum: Verwende dieses Element für ein verschachteltes Dictionary oder eine wiederholte Liste mit einheitlicher Form.

Beispiel

1
<nestedKey name="items"/>

Entscheidungshilfe

Fachlicher Nutzen: Modelliert ein strukturiertes Objekt oder eine wiederholte Datensatzgruppe ohne fachliche Struktur zu verflachen.

  • Verwenden, wenn

    • Wenn ein Ausgabefeld ein Dictionary oder wiederholte Datensätze gemeinsamer Form enthält.
  • Anderen Ansatz wählen, wenn

    • Wenn der Wert skalar, ein homogenes skalares Array oder eine heterogene bedingte Liste ist.
  • Voraussetzungen

    • Definiere die verschachtelten Felder und die beabsichtigte Kardinalität oder Quelle.
  • Alternativen

    • Verwende array für homogene skalare Sammlungen. (Siehe: <array>)
    • Verwende list für Einträge unterschiedlicher Form oder Bedingung. (Siehe: <list>)

Vollständige Beispiele

Verschachtelte Objekte, bedingte Listen, Arrays und Zweige zusammensetzen

Verwende diese Form, wenn ein deterministisches Produkt verschachtelte Datensätze, heterogene Listeneinträge, Literal-Arrays und exklusive Felder kombiniert.

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>

Regeln und ungültige Kombinationen

cyclic erfordert eine Eingabe aus source oder script.

Attribute: cyclic, source, script

Warum: Nur eine vorhandene Eingabesequenz kann wiederholt werden.

Gültige Kombination
1
<nestedKey name="items" count="2" cyclic="true" script="[{'id': 1}]"/>
Ungültige Kombination
1
<nestedKey name="items" count="2" cyclic="true"/>
cyclic erfordert count, minCount oder maxCount.

Attribute: cyclic, count, minCount, maxCount

Warum: Eine endliche Anzahlgrenze verhindert eine endlos wiederholte verschachtelte Eingabe.

Gültige Kombination
1
<nestedKey name="items" count="2" cyclic="true" script="[{'id': 1}]"/>
Ungültige Kombination
1
<nestedKey name="items" script="[{'id': 1}]" cyclic="true"/>
script darf nicht mit Attributen zum Quellenlesen kombiniert werden.

Attribute: script, source, type, separator, sourceScripted

Warum: Ein Skript besitzt den vollständigen verschachtelten Wert; source, type, separator und sourceScripted beschreiben einen anderen Eingabe-Owner.

Gültige Kombination
1
<nestedKey name="items" script="[{'id': 1}]"/>
Ungültige Kombination
1
<nestedKey name="items" script="[{'id': 1}]" source="data/items.ent.csv"/>
distribution erfordert eine listenfähige source.

Attribute: distribution, source, type

Warum: Eine Distribution wählt Datensätze aus einem Quellpool und kann keinen Skalar oder ein quellfreies Objekt formen.

Gültige Kombination
1
<nestedKey name="items" source="mem" distribution="ordered"/>
Ungültige Kombination
1
<nestedKey name="items" source="data/items.ent.csv" distribution="ordered"/>
Verwende count oder minCount/maxCount, niemals beides.

Attribute: count, minCount, maxCount

Warum: Beide Strategien bestimmen die Anzahl verschachtelter Werte.

Gültige Kombination
1
<nestedKey name="items" type="list" count="2"/>
Ungültige Kombination
1
<nestedKey name="items" type="list" count="2" minCount="1"/>
minCount muss kleiner oder gleich maxCount sein.

Attribute: minCount, maxCount

Warum: Die verschachtelte Wiederholungsanzahl wird aus dem inklusiven Intervall zwischen diesen Grenzen gezogen.

Gültige Kombination
1
<nestedKey name="items" type="list" minCount="1" maxCount="3"/>
Ungültige Kombination
1
<nestedKey name="items" type="list" minCount="3" maxCount="1"/>
Eine quellfreie Liste erfordert count, minCount oder maxCount.

Attribute: type, source, count, minCount, maxCount

Warum: Andernfalls kann die Listenlänge nicht bestimmt werden.

Gültige Kombination
1
<nestedKey name="items" type="list" count="2"/>
Ungültige Kombination
1
<nestedKey name="items" type="list"/>
separator und sourceScripted erfordern source.

Attribute: source, separator, sourceScripted

Warum: Diese Optionen verändern das Parsen der Quelle und wirken nicht auf skript- oder kindeigene Werte.

Gültige Kombination
1
<nestedKey name="items" source="data/items.ent.csv" separator=","/>
Ungültige Kombination
1
<nestedKey name="items" count="1" separator=","/>
type darf nicht von sourceEntity abweichen.

Attribute: source, type, sourceEntity

Warum: Bei source='mem' ist ein Entity-Wert in type ein Alias für sourceEntity; ein ausdrücklich anderer sourceEntity-Wert wäre mehrdeutig.

Gültige Kombination
1
<nestedKey name="items" type="list" source="mem" sourceEntity="orders"/>
Ungültige Kombination
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}'

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

Lösung: Provide a dictionary value for the configuration.

Vollständige Regel

I192 — Source Reference Identifier Empty

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

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

Lösung: Add the source identifier after the URI scheme and retry.

Vollständige Regel

I193 — Source Reference Consumer Unsupported

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

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

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

Vollständige Regel

I195 — Source Reference Identifier Conflict

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

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

Lösung: Remove the legacy override or make it equal to the identifier in source.

Vollständige Regel

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.

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

Lösung: Move the dataset name to sourceEntity; reserve type for list or dict.

Vollständige Regel

Erlaubte Elternelemente / Erlaubte Kindelemente

Erlaubte Elternelemente: else, else-if, generate, if, item, iterate, nestedKey, while

Erlaubte Kindelemente:

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

Attribute

Alle 17 Attribute anzeigen

condition

Condition for nested key generation.

optional; string; Standardwert: null.

converter

Converter for element data transformation.

optional; string; Standardwert: null.

count

Number of nested keys to generate.

optional; string; Standardwert: null.

cyclic

Enable or disable cyclic generation for nested keys.

optional; boolean; Standardwert: null.

defaultValue

Default value for nested keys.

optional; string; Standardwert: null.

distribution

Distribution type for nested key sampling.

optional; string; Standardwert: null; Werte: ordered, random, round_robin, reservoir, cumulated.

maxCount

Maximum count for nested key generation.

optional; integer; Standardwert: null.

minCount

Minimum count for nested key generation.

optional; integer; Standardwert: null.

name

Name of the nested key.

erforderlich; string.

script

Script for nested key generation.

optional; string; Standardwert: null.

separator

Separator for nested key data.

optional; string; Standardwert: null.

source

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

optional; string; Standardwert: null.

sourceEntity

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

optional; string; Standardwert: null.

sourceScripted

Enable or disable scripted sources.

optional; boolean; Standardwert: null.

type

Type of the nested key.

optional; string; Standardwert: null; Werte: list, dict.

variablePrefix

Prefix before field names inside nested selectors.

optional; string; Standardwert: null.

variableSuffix

Suffix after field names inside nested selectors.

optional; string; Standardwert: null.