Please enable JavaScript to view this site.

Altova MapForce 2020 Professional Edition

Result is the input string split into a sequence of chunks/sections defined by the length parameter. The result can then be passed on for further processing.

fn-tokenizebyLeng

E.g. Input string is ABCDEF and length is "2" - then result is AB CD EF.

 

Example

The tokenizeString2.mfd file available in the ...\MapForceExamples folder shows how the tokenize-by-length function is used.

tok-len01

The XML source file is shown below, and is the same as the one used in the previous example. The MissionKit element also has two attributes: Edition and ToolCodes, but no MissionKit element content.

tok-len1

The aim of the mapping is to generate a list showing which Altova tools are part of the respective MissionKit editions.

 

How the mapping works:

 

The SelectMissionKit Input component receives its default input from a constant component, in this case "Enterprise XML Developers".

The equal function compares the input value with the "Edition" value and passes on the result to the bool parameter of the ToolCodes filter.

The node/row input of the ToolCodes filter is supplied by the ToolCodes item of the source file. The value for the Enterprise XML Developers edition is: XSMFSVDDSASW.

The XSMFSVDDSASW value is passed to the on-true parameter, and further to the input parameter of the tokenize-by-length function.

 

What the tokenize-by-length function does:

 

The ToolCodes input value XSMFSVDDSASW, is split into multiple chunks of two characters each, defined by length parameter, which is 2, thus giving 6 chunks.

Each chunk (placed in the b parameter) of the equal function, is compared to the 2 character Code value of the source file (of which there are 9 entries/items in total).

The result of the comparison (true/false) is passed on to the bool parameter of the filter.

Note that all chunks, of the tokenize-by-length function, are passed on to the node/row parameter of the filter.

The exists functions now checks for existing/non-existing nodes passed on to it by the on-true parameter of the filter component. Existing nodes are those where there is a match between the ToolCodes chunk and the Code value. Non-existing nodes are where there was no ToolCodes chunk to match a Code value.

The bool results of the exists function are passed on to the if-else function which passes on a Y to the target if the node exists, or a N, if the node does not exist.

 

Result of the mapping:

tok-len2

© 2019 Altova GmbH