Scripted Source Templates¶
Use sourceScripted="true" when a versioned project file is a data template whose values must be evaluated in the current record context. Keep it disabled for ordinary source data: enabling it turns file values into executable expressions.
Two replacement forms have different contracts:
- A complete value such as
{40 + 2}is evaluated as an expression and retains its result type. The example therefore produces the integer42, not the string"42". - A placeholder inside text, such as
customer-__row_number__, performs string substitution.variablePrefixandvariableSuffixcan replace the default__delimiters.
| data/people.ent.csv | |
|---|---|
1 2 3 4 | |
| scripted-source.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 | |
The output ages are integers 42, 37, and 29; the labels are customer-1, customer-2, and customer-3.
Do not confuse the three mechanisms¶
sourceScriptedevaluates values read from a supported project file.scripton a field computes that one field.scriptas the execution basis of a nestedgenerateowns the complete record or record-list value. A dictionary represents one record; a list of dictionaries represents several records.
Use the narrowest mechanism that expresses the requirement. A normal data file is easier to audit than an executable template, and a typed generator or field intent is easier for Authoring to validate than an arbitrary script.
Boundaries¶
- Expressions run with the current DATAMIMIC evaluation namespace; they are not interpolated during descriptor parsing.
- A brace expression must occupy the complete source value. Text around it prevents expression evaluation.
- Embedded prefix/suffix replacement always produces text.
- Source-column names and variables should not shadow one another; use distinct business names so the dependency is reviewable.
- Keep the read bounded and select a distribution supported by the source family.
See sourceScripted, variablePrefix, and variableSuffix for the generated attribute contract and expression lifetime for descriptor expressions.