Altova MapForce 2024 Enterprise Edition


Using the Switch option allows you to define multiple keywords, or conditions, for a single text fragment. Each keyword you define, has its own associated container which receives data only if the specific condition is satisfied, i.e. true. If none of the conditions are satisfied, then the specific fragment is mapped to a "default" container.


Container default settings are:


Output                For the first triggered condition.


The example below processes a Tomcat log file, where the individual processes are to be separated out, and made mappable. When you first define a Switch container, only the default container appears to the right of the Switch container. All data is automatically passed on to it.



The repeated split container, using delimited (line based), separates all INFO sections out of the log file and passes them on to the Switch container.


1.Click the append icon ic-fl-append to add a new condition to the Switch container.

2.Double click in the "Content starts with" field, enter "Initializ" and hit Return.


A new container is added. Data will be forwarded to this container if the condition is true. If not, the data is forwarded to the default container.


3.Click the "Content starts with" combo box, and change it to "Content contains". The first condition has now been defined and you can see the result below.  The first fragment does not contain "Initializ", and its contents are therefore forwarded to the default container.


4.Click the Display next block icon ic-flex-next, to see the next text fragment.


The Initializing... fragment now appears in its associated container, and the default container is empty. Stepping through the fragments gives you a preview of what the individual containers hold.


5.Click the container icon button, and select Store as value.


6.Double click in the "Store" title bar and change the text e.g. Initialize.


7.Click the append icon ic-fl-append to add a new condition to the Switch container.

8.Double click in the "Content starts with" field, enter "Starting" and hit Return. You can add as many conditions as you need e.g. Pausing, and Stopping. Give each of the associated containers a name, to make recognition in MapForce easier.


The screenshot above shows all four conditions, and the contents of the "Starting" container at block/fragment no 4. The associated containers have all been renamed to make identification in the MapForce component easier.


Note that conditions can be moved up and down in the condition list, using the respective Move Up/Down buttons ic-fl-movup, or ic-fl-movdw.


9.Save the template and insert it in MapForce.

Note:If a text fragment in the current fragment satisfies a condition, then the complete data of that fragment is passed on to the associated container. Data is not split up in any way, it is just routed to the associated containers, or to the default container if it does not satisfy any of the defined conditions.


The associated containers produced by Switch, can be used for further processing. You can change such a container to Split once, Repeated split, or anything else if you wish.


Content starts with:

Data is only passed to the associated container, if the condition string appears at the start of the text fragment.


Content contains:

Data is passed on to the associated container, if the condition string appears anywhere in the text fragment.


For the first triggered condition:

Data is passed on when one of the conditions in the condition list is true. Any other conditions that are true are ignored, and no data is passed on to any of the associated containers.


For all triggered conditions:

Outputs data for every condition that is true in the condition list. This makes it possible to have multiple occurrences of the same data/fragment in multiple associated containers simultaneously. This might occur if a text fragment contains text that satisfies two conditions simultaneously e.g. "initializing starting sequence" in the example above.

© 2018-2024 Altova GmbH