Variables
Overview
The DataMapper supports xsl:variable as first-class mapping sources. Variables appear in the Variables panel on the source side and can be dragged onto target fields just like schema fields.
Variables have two scopes:
- Global (template-level) — defined at the top of the
xsl:template, available anywhere in the mapping. Created from the Variables panel header. - Local (node-scoped) — defined as a child of a container field or instruction node, available to that node’s content and its following siblings within the same scope. Created from the
⋮mapping context menu.
The XSLT following-sibling rule applies: a local variable can only be referenced by fields that come after it in the same scope. The DataMapper enforces this during drag-and-drop — drops that would violate the rule are rejected.
The Variables Panel
The Variables panel sits at the top of the source tree, above the Parameters and Source Body sections. It lists all variables available at the current mapping scope.

Each variable row shows:
- The variable name prefixed with
$ - A scope hint in parentheses for local variables (e.g.
(ShipTo)meaning the variable is defined inside theShipTofield’s scope) - For global variables: an inline XPath input and fx button to set or edit the variable’s value expression
- A delete (trash) button
Add a Global Variable
A global variable is available throughout the entire mapping. Use it to compute a value once and reference it in multiple target fields.
Steps
- Click the
+button in the Variables panel header

Type the variable name and press Enter to confirm (or Escape to cancel)
Enter the value expression in the inline XPath input that appears on the variable row, or click the fx icon to open the XPath Editor
Variable names must be valid XPath NCNames (no spaces, no $ prefix — the $ is added automatically when referencing the variable in expressions).
Add a Local Variable
A local variable is added as a child of a container field or instruction node — the xsl:variable is placed inside that node’s scope in the generated XSLT, available to its content and following siblings.
Steps
- Click the
⋮menu on the target field where you want to define the variable - Select “Add variable”

- Type the variable name and press Enter to confirm
Local variables do not have an inline expression input in the Variables panel — their value is set by mapping source fields onto the variable row, just like any other target field.
“Add variable” only appears in the ⋮ menu on container fields (fields that have children) and on instruction nodes such as for-each, for-each-group, if, when, and otherwise. It is not available on leaf fields.
Use a Variable as a Mapping Source
Once a variable exists in the Variables panel, drag it onto a target field to create a Var:// reference in the generated XPath.
Steps
- Locate the variable in the Variables panel
- Drag it onto a target field — the mapping line shows a
Var://prefix to indicate the source is a variable reference - The generated XPath expression references the variable as
$variableName

You can also type $variableName directly in the inline XPath input or in the XPath Editor rather than dragging.
Rename a Variable
Renaming a variable updates all mapping expressions that reference it.
Double-click the variable name in the Variables panel, or right-click the variable row and select “Rename”. Type the new name and press Enter.
Renaming is safe — the DataMapper automatically updates all XPath expressions that reference the old name throughout the mapping tree.
Delete a Variable
Click the trash icon on the variable row. A confirmation dialog appears.
Deleting a variable removes all mappings that reference it. This cannot be undone.
Hide and Show Variables
Click the eye icon in the Variables panel header to toggle visibility of the variable list. This collapses the panel visually but does not affect the generated XSLT.
Next Steps
- XPath Editor — write complex expressions in the variable definition, or reference variables
- Loop Mappings — variables are particularly useful inside
for-eachandfor-each-groupscopes to capture intermediate values