You can use transformation variables in order to keep values that you plan to reuse later. For example, if calculation of a value takes time it might be more efficient to create a transformation variable for the value and then reuse this variable. See Using local variables in transformations.A variable is introduced in the current evaluation scope, and its corresponding XPath expression is evaluated. All variables are evaluated in the declaration order, but after the host element evaluation.
<tdt:rule path="/data/day">
<!-- variables are evaluated in declaration order -->
<tdt:value key="$hello">'Hello'</tdt:value>
<tdt:value key="$world">'World'</tdt:value>
<tdt:value key="$greeting">concat($hello, ' ', $world)</tdt:value>
<!-- No access to variables(host evaluated before) -->
<tdt:value key=".">...</tdt:value>
</tdt:rule>When you define a variable for an element, its value can be used in the element and in all its descendants (not in siblings or parent elements). You can re-define the variable on each descendant level, but you can only define it once at each level. If you re-define the variable on a child element, the new value is used in this scope. Outside this scope, the value of the parent is used.
<tdt:rule path="/data/day/station">
<!-- Access to variables from '/data/day' rule ($hello, $world, $greeting) -->
<tdt:value key=".">...</tdt:value>
<tdt:value key="$greeting">concat($hello, ' beautiful ', $world)
</tdt:value>
</tdt:rule>
<tdt:rule path="/data/day/station/name">
<!-- Here $greeting equals 'hello beautiful world' -->
</tdt:rule>
<tdt:rule path="/data/day/conclusion">
<!-- Here $greeting equals 'hello world' -->
</tdt:rule>
<tdt:rule path="/data/night">
<!-- Here $greeting is not accessible -->
</tdt:rule>
| OpenText StreamServe 5.6.2 | Updated: 2018-01-26 |