You can use local 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. Another scenario when transformation variables should be used is described in Example – using a variable to access lookup data.The following example illustrates a simple usage scenario where a text node will contain the string Hello World in the output.
$hello 'Hello' $world 'World' $greeting concat($hello, ' ', $world) text() $greetingLocal transformation variables are evaluated in declaration order. In the example above, the variables are evaluated in this order: $hello - $world - $greeting. If the order in the example would be $greeting - $hello - $world then the $greeting variable would not be evaluated correctly.The following examples illustrate incorrect and correct definitions of variables (for visibility, the syntax described in Data transformation persistence is used).<tdt:rule path="/data/sentence">
<tdt:value key="$address">'http://'</tdt:value>
<tdt:value key="$address">concat($address, 'example.com')
</tdt:value>
</tdt:rule><tdt:rule path="/data">
<tdt:value key="$address">'http://'</tdt:value>
</tdt:rule>
<tdt:rule path="/data/sentence">
<tdt:value key="$address">concat($address, 'example.com')
</tdt:value>
</tdt:rule>For repeated elements the variables are evaluated again and again for every iteration. In the following example the $position variable has values 1, 2, 3, ...
/data/message/sentence $position position()
•
•
•
• The previous example with concat($hello, $world) works for the string variables $hello and $world. Using $hello | $world would fail since | is only defined for node-sets.Note that StoryTeller variables accessed from presentation always are node-set, which means $hello | $world would work in presentation.
| OpenText StreamServe 5.6.2 | Updated: 2018-01-26 |