Skip to content

Element <array>

Purpose: Generate a repeated array from a literal value set or scripted source.

Why: Use it for a homogeneous scalar collection produced from literals, a script, or a typed count.

Example

1
<array name="items" type="string" count="1"/>

Decision guide

Business value: Expresses a homogeneous scalar collection as one field in the product contract.

  • Use when

    • All array entries share one scalar type or come from one repeated expression.
  • Choose another approach when

    • Entries have different structures or contain nested business records.
  • Prerequisites

    • Select a literal, scripted, or counted array strategy.
  • Alternatives

    • Use list for heterogeneous or conditional entries. (See: <list>)
    • Use nestedKey for repeated structured records. (See: <nestedKey>)

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

script cannot be combined with type or count.

Attributes: script, type, count

Why: The script returns the complete array, so a separate element type or repetition count is ambiguous.

Valid combination
1
<array name="scores" script="[10, 20, 30]"/>
Invalid combination
1
<array name="scores" script="[10, 20, 30]" type="int"/>
A non-script array requires both type and count.

Attributes: type, count, script

Why: DataMimic needs the scalar type and the number of repeated child values when no script owns the array.

Valid combination
1
<array name="scores" type="int" count="3"/>
Invalid combination
1
<array name="scores" type="int"/>
type='literal' rejects script and count.

Attributes: type, script, count

Why: A literal array obtains its stable contents from ordered children.

Valid combination
1
<array name="channels" type="literal"/>
Invalid combination
1
<array name="channels" type="literal" count="2"/>
I611 β€” Parser Array Subelements Not Allowed

Element '{name}' does not accept sub-elements unless type is '{data_type}'

Why: An error occurred during descriptor parsing.

Resolution: Review the configuration and retry.

Full rule

I612 β€” Parser Array Literal Empty

Literal array '{name}' must define at least one element

Why: The configuration violates the requirement that Literal array '{name}' must define at least oneelement.

Resolution: Provide a non-empty configuration and retry.

Full rule

I613 β€” Parser Array Value Invalid

Failed while parsing attributes of element <{child_tag}> inside '{name}': {details}

Why: The system failed while parsing attributes of element <{child_tag}> inside '{name}': {details}.

Resolution: Correct the configuration to a valid value or configuration.

Full rule

I804 β€” Task Array Script Element Type

Failed while evaluate script '{script}' of '{name}': expect array element datatypes in ({valid_types}), but got invalid datatype '{element_type}'

Why: The system failed while evaluate script '{script}' of '{name}': expect array element datatypesin({valid_types}), but got invalid datatype '{element_type}'.

Resolution: Review the configuration and retry.

Full rule

I805 β€” Task Array Script Mixed Types

Failed while evaluate script '{script}' of '{name}': all elements in list must be the same data type

Why: The system failed while evaluate script '{script}' of '{name}': all elements in list must be thesamedata type.

Resolution: Review the configuration and retry.

Full rule

I806 β€” Task Array Script Not List

expect datatype list of evaluated script '{script}' of '{name}', but got invalid datatype '{value_type}'

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

Resolution: Provide a list value for the script.

Full rule

Allowed parents / Allowed children

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

Allowed children:

value

  • Structured Data and Rule Pipelines β€” Shows how composite output shapes and the ordered source-filter, mapping, and target-filter pipeline work together without hiding phase boundaries.

Attributes

Show all 4 attributes

count

Number of elements in the array.

optional; integer; Default: null.

name

Name of the array.

required; string.

script

Script for generating array elements.

optional; string; Default: null.

type

Data type of the array.

optional; string; Default: null; Values: string, int, float, bool, literal.