Adding a Variable to a Mapping

Variables can be used in any XPath expression within the message panel.

Choosing this option opens a dialog that enables you to specify the name of the variable. You can change the name of the variable at a later time by selecting the variable and clicking the Show Edit Tab button in the toolbar. The Variable Name field can be used to change the variable’s name.

Procedure

  1. The value of the variable is specified by supplying an XPath expression, either by mapping data from the context panel or by using XPath functions or constants.
  2. Once the variable’s contents have been supplied, the variable can be referenced within the scope that it has been defined. That is, you can r eference a variable from within the same component or within sub-components of the component in which the variable is defined.
    Adding a variable is useful if you perform the same computation repeatedly. You can refer to the results of the computation in several message elements instead of recreating the computation for each item.
    In this example, the variable uses the mediation flow property USDtoYenXChangeRate to get the value of the current exchange rate. That value is then multiplied by 1.02 to add a 2% markup. The variable can then be referenced in subsequent statements in the mapping.
    An example of adding a variable to a mapping