Altova MapForce 2022 Professional Edition

Creating Defaults and Node Functions

Home Prev Top Next

You can create node functions or defaults for nearly any item (node) on the mapping. Let's call this process defining a rule.


In order to create a rule, first determine the item (node, or field) where you want to define the rule. This can be either a "leaf" item (with no descendants) or an item that has descendants. In the latter case, you can apply the rule to all descendant items as well. Moreover, you can filter descendant items on which you want the rule to apply, by data type. You can also look up qualifying items by type and name, with the help of regular expressions.




You can create defaults or node functions either on an input side of a target component, or on the output side of a source component. To establish which side is right for your needs, see Choosing the Input or Output Side.

Defaults and node functions require that the connection type between source and target is either "Source Driven" or Target Driven". "Copy-All" connections are not supported. Specifically, node functions and defaults are not applied to descendants of "Copy-All" connections. The node that has the "Copy-all" connection itself will apply node functions and defaults, but only if it has a simple value, for example, an XML element with simple-type content and attributes. Therefore, if you want to define a function or set a default on a node with descendants, the connection type between source and target must not be "Copy-All". To view or change the connection type, right-click the connection and select Target Driven (Standard) from the context menu. For more information, see Connection Types.

Note that creating defaults or node functions is not supported for the "File" node. This node lets you create or read file names dynamically, see Processing Multiple Input or Output Files Dynamically.

To create a rule:

1.Right-click the item (node) of interest, and select Node Functions and Defaults | Input Node Functions and Defaults from the context menu (or Output Node Functions and Defaults, depending on the case). Alternatively, right-click a connector—in this case, MapForce will show the node function command for that side only. The Mapping pane displays a grid at the top, for example:


If the item where you define the rule has a parent, the parent may also have rules (node functions or defaults) defined against it. To inherit such rules, select the Inherit rules from ancestors check box. For more information about inheritance, see How Defaults and Node Functions Work.


2.Do one of the following:

a.To add a default, click Add Default ( mf_ic_add_default  ).

b.To add a function, click Add Function ( mf_ic_add_nodefunc ).


This creates a new rule (a row in the grid at the top of the Mapping pane where you can choose the criteria for this rule). Configure the rule as follows:


Apply To

Select whether the rule should apply to the current item, or to all descendant items regardless of their depth, or to direct child items only.


If the item you selected in step 1 has no descendants, then "Current item" is the only choice.

Data Type

Click the Ellipsis button mf_ic_ellipsis and select a data type from the dialog box. The rule (default or node function) will apply only to items that have this data type (or a derived data type). For more information, see Applying Node Functions and Defaults Conditionally.


If the item you selected in step 1 is has no descendants, then the item's data type is the only choice.

Default Value / Function Description

If you are defining a default ( mf_ic_add_default ), type here the default value that you wish to set for the selected item (and all descendants, if applicable). To set an empty string as default, leave this field empty.


If you are defining a function ( mf_ic_add_nodefunc ), this field is for information purpose only. It displays a summary of the function. You can define the function's body in the next step.


3.If you are defining a function, the mapping area changes to display the function's input (illustrated below as "raw_value") and output ("result"). This mapping area is a mini-mapping, and the same general rules apply here as when you define a standard mapping. For example, the body of a function could look as follows:


The node function illustrated above replaces any empty value with the value "n/a". For more information about this example, see Example: Replace Empty CSV Fields.


Note the following:


Inside a node function, only certain MapForce components meaningful in this context are supported, such as built-in functions, variables, if-else conditions, and others. Complex structures such as XML, JSON, EDI, or databases are not supported. Adding inline user-defined functions or join components to a node function is also not supported.

A node function can have one input parameter at most, or no parameter at all. The input parameter is always called "raw_value". Never delete the input parameter ("raw_value"), even if you don't need an input for your function; otherwise, validation errors will appear when you run the mapping. The same applies for the function's output. Should you need to restore an accidentally deleted input component, run the menu command Function | Insert Input.

If an input parameter ("raw_value") is already present, any subsequent input parameters that you add become metadata parameters. You can use such metadata to retrieve additional information about the current node and use it inside the function, see Supplying Node Metadata to Node Functions.

In some cases, you might find it more convenient to create a node function as follows: drag a function from the Libraries window to an input or output connector. This makes sense only for simple functions like right-trim or uppercase.

To exit to the main mapping:

Click the Go back mf_ic_exit_door button in the upper-left corner of the Mapping pane, or press Escape.


See also Editing and Deleting Existing Rules.

© 2016-2022 Altova GmbH