Skip to content

Element <field>

Purpose: One source-column to target-field mapping within a reference statement.

Why: Use it inside a reference to make source-to-target field mapping explicit.

Example

1
<field target="customer_id" sourceKey="id"/>

Decision guide

Business value: Makes each correlated source-to-target column mapping visible inside a reference.

  • Use when

    • Selecting one named source column for one named output field in a reference.
  • Choose another approach when

    • Defining a standalone generated field outside a reference.
  • Prerequisites

    • Place it directly inside reference and name both sides of the mapping.
  • Alternatives

    • Use key for independently generated or scripted fields. (See: <key>)

Complete examples

Copy correlated fields from one weighted customer row

Use one reference with field children when several foreign-key values must always come from the same selected source record.

correlated-reference/data/customers.wgt.ent.csv
1
2
3
id|country|weight
1|DE|1
2|FR|1
correlated-reference/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<setup numProcess="1">
    <generate name="orders" count="2" target="LogExporter">
        <id name="order_id" generator="IncrementGenerator"/>
        <reference name="customer"
                   source="data/customers.wgt.ent.csv"
                   weightColumn="weight">
            <field target="customer_id" sourceKey="id"/>
            <field target="customer_country" sourceKey="country"/>
        </reference>
    </generate>
</setup>

Rules and invalid combinations

No additional element-specific rules. Required attributes, types, and supported values are shown below.

Allowed parents / Allowed children

Allowed parents: else, else-if, if, reference, while

Allowed children:

None

Attributes

Show all 2 attributes

sourceKey

Source column name in the reference source.

required; string.

target

Target field name that receives the sampled value.

required; string.