Dynamic Includes and Fragment Parameters¶
Use dynamic includes when one descriptor should compose different XML fragments or reuse the same fragment with different inputs. DATAMIMIC supports two separate mechanisms:
{expression}ininclude uriselects the file at setup time.- Child
<property>elements pass scoped values into an XML fragment. The fragment may declare its expected inputs with<param>.
Both mechanisms are part of the Core DSL. Platform-specific per-run file injection is described separately in Inject runtime properties through the Platform API.
Select an included file through properties¶
Properties are loaded in document order. A placeholder must therefore be defined before the <include> that uses it. Later property files replace earlier values with the same name.
| examples/properties/conf/runtime.properties | |
|---|---|
1 2 | |
| examples/properties/models/load_performance.xml | |
|---|---|
1 2 3 4 5 | |
| examples/properties/datamimic.xml | |
|---|---|
1 2 3 4 | |
This pattern is useful for CI variants, load-test volumes and feature-specific model fragments. Every resolved path must stay inside the descriptor workspace.
Declare a reusable fragment contract¶
An XML fragment uses <param> to state which values callers may supply. A parameter can be a string, int, enum or safe relative path; default makes it optional. Enum values are whitespace-separated.
| examples/fragments/fragments/payment.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
The caller supplies values with child <property> elements. constant is a literal call-site value; exactly one of constant and script is allowed.
| examples/fragments/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 | |
The first call produces three SEPA records. The second uses the declared default and produces two SWIFT records. Missing required parameters fail with I618; invalid types, enum values or unsafe paths fail with I619.
Compute fragment parameters per source row¶
script uses normal DATAMIMIC expression semantics without braces. Inside a <generate>, it is evaluated for every caller row and can read that row's fields and variables.
| examples/per-row/fragments/payment.xml | |
|---|---|
1 2 3 4 5 6 7 8 | |
| examples/per-row/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
The fragment is executed three times with the direct caller's current idx. Writing script="{idx}" is invalid because braces belong to setup-attribute interpolation, not normal script= evaluation.
Scope and evaluation rules¶
- Include properties are visible while parsing and executing the included XML fragment.
- Nested includes inherit them.
- They never leak back into the parent descriptor.
- A literal
.propertiesinclude cannot have child<property>elements. - A dynamic URI that resolves to
.propertiesrejects child properties at runtime withI208. - A
.propertiesinclude condition is decided at parse time from properties already loaded before it. - An XML include condition is evaluated at runtime in the current execution context and must return a boolean.
uri="{expression}"must resolve to a string and must remain inside the descriptor workspace.
Error handling¶
| Code | Meaning |
|---|---|
I201 |
Included file was not found. |
I202 |
Included properties could not be parsed. |
I203 / I204 |
File type is unsupported in setup/generate context. |
I205 |
Include condition did not return a boolean. |
I206 |
Include condition evaluation failed. |
I207 |
Resolved path escapes the descriptor workspace. |
I208 |
Child properties were combined with a properties-file include. |
I618 |
A required fragment parameter is missing. |
I619 |
A fragment parameter violates its declared contract. |
Choosing the mechanism¶
- Use property files for run-wide configuration and dynamic fragment selection.
- Use
<param>plus<include><property>for a reusable XML fragment with an explicit local interface. - Use
constantwhen the call site knows the value statically. - Use
scriptonly when the value must come from the current runtime row or scope.
Related references: <include>, <property>, and <param>.