Liquid Data Mapper – Scalar Components

Liquid Data Mapper - Scalar Components

The Liquid Data Mapper facilitates complex data transformations by utilizing scalar components, which process single primitive values from sequences. Each scalar function can convert inputs sequentially, returning transformed values. Examples illustrate how components like ‘Upper’ and ‘Left’ work, producing evaluated sequences.


The Liquid Data Mapper makes building complex data transformations quick and easy, but before you start there are a few basic concepts you need to learn.

Scalar Components

A Scalar component is one that takes primitive input values and return a single primitive value. However, the previous article ‘Sequences‘, shows that the value returned from a connection point is always a sequence of values, i.e. a set of zero or more (0-n) values.

Clearly if scalar components only operate on single values but connection points always convey sequences, then we need to be able to convert between them. The problem is resolved by extracting the values from the incoming sequence and feeding them to the underlying scalar function one at a time.

Notation – For these examples, curly brackets are used to describe the contents of a sequence:
    {‘A’} is a sequence containing a single value ‘A’
    {} is an empty sequence
    {‘A’, ’B’} is sequence containing 2 values ‘A’ & ’B’


Liquid Data Mapper - Scalar Components
Liquid Data Mapper – Scalar Components

In this example, the ‘Upper 1’ component is processed as follows:

      FOREACH value1 IN inputSequenceString
             RETURN_VALUE ConvertToUpper (value1)

The sequence returned from the ‘Upper 1’ component is:
    { ConvertToUpper (‘a’), ConvertToUpper (‘b’), ConvertToUpper (‘c’) }

Which evaluates to the sequence:
    { ‘A’, ‘B’, ‘C’ }

<!–Created by Liquid Data Mapper Libraries (www.liquid-technologies.com)–>

<Contacts>

    <ContactDetails>

        <Name>A</Name>

        <Name>B</Name>

        <Name>C</Name>

    </ContactDetails>

</Contacts>

Scalar components with one input behave as you would expect, but scalar components with two or more inputs have a more noticeable effect of this transform.

Liquid Data Mapper - Scalar Components
Liquid Data Mapper – Scalar Components

In this example, the string ‘Left’ component (which takes the first n chars from the input string) has the inputs ‘String’ values and ‘Length’ values and it is evaluated as follows:

FOREACH stringValue in InputSequenceString
      FOREACH lengthValue in InputSequenceLength
             RETURN_VALUE GetStringLeft (stringValue, lengthValue)

So in this case the ‘String’ contains the sequence {‘ABCDEFGHIJ’, ‘qrstuvwxyz’}, and the ‘Length’ input contains the sequence {1, 4}, the resulting sequence is:

    { GetStringLeft (‘ABCDEFGHIJ’, 1), GetStringLeft(‘ABCDEFGHIJ’, 4), GetStringLeft(‘qrstuvwxyz’, 1), GetStringLeft(‘qrstuvwxyz’, 4)}

Which evaluates to
     {‘A’, ‘ABCD’, ‘q’, ‘qrst’}

The result is the Cartesian product of the inputs:

<!–Created by Liquid Data Mapper Libraries (www.liquid-technologies.com)–>

<Contacts>

    <ContactDetails>

        <Name>A</Name>

        <Name>ABCD</Name>

        <Name>q</Name>

        <Name>qrst</Name>

    </ContactDetails>

</Contacts>

Tip: Execute the transform by pressing Shift-F5.Debug the transform by pressing F5 to start the debugger
    F11 – Step Into
    F9  – Set break point
    F5 – Run (stops on break points)

A free trial of the Liquid Data Mapper is available from:
https://www.liquid-technologies.com/trial-download

Discover more from Liquid Technologies Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading