Altova MapForce 2025 Professional Edition

Example: Previewing Function Output

Home Prev Top Next

This example illustrates how to preview the output returned by MapForce functions with the help of simple output components. You will make the most of this example if you already have a basic understanding of functions in general, and of MapForce functions in particular. If you are new to MapForce functions, you may want to refer to Using Functions before continuing.

 

Our aim is to add a number of functions to the mapping area, and learn how to preview their output with the help of simple output components. In particular, the example uses a few simple functions available in the core library. Here is a summary of their usage:

 

string-length

Returns the number of characters in the string provided as argument. For example, if you pass to this function the value "Lorem ipsum", the result is "11", since this is the number of characters that the text "Lorem ipsum" takes.

substring-after

Returns the part of the string that occurs after the separator provided as argument. For example, if you pass to this function the value "Lorem ipsum" and the space character (" "), the result is "ipsum".

substring-before

Returns the part of the string that occurs before the separator provided as argument. For example, if you pass to this function the value "Lorem ipsum" and the space character (" "), the result is "Lorem".

 

To test each of these functions against a custom text value ("Lorem ipsum", in this example), follow the steps below:

 

1.Add a constant with the value "Lorem ipsum" to the mapping area (use the menu command Insert | Constant). The constant will be the input parameter for each of the functions to be tested.

2.Add the string-length, substring-after, and substring-before functions to the mapping area, by dragging them to the mapping area from the core library, string functions section.

3.Add a constant with an empty space (" ") as value. This will be the separator parameter required by the substring-after and substring-before functions.

4.Add three simple output components (use the menu command Function | Insert Output). In this example, they have been named Result1, Result2, and Result3, although you can give them another title.

5.Connect the components as illustrated below.

map_test_function_output

Testing function output with simple output components

As shown in the sample above, the "Lorem ipsum" string acts as input parameter to each of the string-length, substring-after, and substring-before functions. In addition to this, the substring-after and substring-before functions take a space value as second input parameter. The Result1, Result2, and Result3 components can be used to preview the result of each function.

To preview the output of any function:

Click the Preview ( ic-preview ) button in the component title bar, and then click the Output pane on the Mapping window.

© 2018-2024 Altova GmbH