Built-in Variables¶
There are six built-in variables in the DTL.
These are _S
, _T
, _P
, _R
, _B
and _
.
_S
refers to the source entity_T
refers to the target entity_P
appears inside theapply
function and refers to the parent context_R
is used to refer to the root context containing both_S
and_T
_B
is used by the HTTP endpoint sinks to hold variables defined by URL parameters_
refers to the current value in functional expressions
Note
_S
and _T
appear in pairs inside each applied transform
Variable |
Description |
Examples |
---|---|---|
|
Refers to the source entity. This is the entity on which the DTL transform operate. Note that with the |
["gt", "_S.age", 42] The source entity’s
age field must have a value greater than 42. |
|
Refers to the target entity. This is the entity that is the
primary target entity of transforming the source entity. Note
that the |
["gt", ["length", "_T.length"], 100] The target entity’s
description field must have a length of
more than 100 characters. |
|
A dict that contains the source entity and the
target entity of the parent context. If the parent context also has
a parent context, then that will also be available. The dict always
contains the |
["gt", "_P._S.age", 18] The parent source entity’s
age field must be greater than 18.["lt", ["length", "_P._P._T.description"], 100] The grandparent target entity’s
description field must have a
length of less than 100 characters. |
|
A dict that contains the source entity and the
target entity of the root context. The root context is the outermost
context, which in practice is the context of the |
["lt", "_R._S.age", 18] The root source entity’s
age field must be less than 18.["lt", ["length", "_R._T.description"], 50] The root target entity’s
description field must have a
length of less than 50 characters. |
|
A dict that contains properties bound to URL parameters. It is useful for parameterizing the transform on an endpoint sink. |
A URL parameter
foo given to the endpoint API on the formhttp://my_host:port/api/publishers/my_endpoint?foo=bar will be reflected in
_B as a key foo with the value “bar”. |
|
Refers to the current entity. This variable is only available
inside a few functions that take a function expression as an
argument. Examples of such functions are |
["filter", ["gt", "_.amount", 100], "_S.orders"]] Filters out the order entities that have an amount of less than
100, i.e. the filter function returns only the orders that have
an amount of greater than 100. As you can see the
_ variable
refers to the individual order entities, one at a time. |