Thursday, June 08, 2017

Liquid Data Mapper - 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.

The value returned from a connection point is always a sequence of values, i.e. a set of zero or more (0-n) values.

Even if the data source only provides a single value such as an attribute value in an XML document, this is dealt with as a sequence that contains a single value. Similarly if a source value is missing, for example an optional element in an XML document, then an empty sequence is returned.

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 - Sequence
Liquid Data Mapper - Sequence
In this simple example we have a 'Constant' component value as data input. This provides the simplest possible sequence as it just returns the sequence {‘A’}. So when it is used to create the Name element in the 'XML Writer', we get a single Name element with the value ‘A’:

<!--Created by Liquid Data Mapper Libraries (www.liquid-technologies.com)-->
<Contacts>
    <ContactDetails>
        <Name>A</Name>
    </ContactDetails>
</Contacts>

Liquid Data Mapper - Sequence
Liquid Data Mapper - Sequence

In this example, three 'Constant' components provide input sequences {‘A’}, {‘B’} and {‘C’} and are used as data inputs to the 'Combine' component. The 'Combine' component combines these into a single sequence {‘A’, ‘B’, ‘C’}. So now as three values are being used to create the Name element in the 'XML Writer', we get three Name elements in the XML:

<!--Created by Liquid Data Mapper Libraries (www.liquid-technologies.com)-->
<Contacts>
    <ContactDetails>
        <Name>A</Name>
        <Name>B</Name>
        <Name>C</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