Liquid XML Studio
Getting Started
Send Feedback
Tutorials > Liquid Data Mapper > Getting Started

Glossary Item Box

A new transform can be created using the File->New menu, and selecting the Data Mapper icon.

Create New Data Mapper Files

When constructing a Data Transformation its often easier to start with the output component and work back.

The XML output component can be found in the Component Palette (If its not visible it can be displayed by selecting it in the View Menu"), and can be added to the data mapper canvas by dragging it on.

XML Data Target

The XML Data Target loads its meta data (i.e. a description of the output document) from an XML Schema (XSD). If you don't have an XSD then its possible to infer one from one or more sample XML files which represent the output data you are trying to create. You could also create or modify a schema using the built in XSD Editor.

When XML Data Target is dropped on the data mapper canvas it starts a wizard which will capture all the data required to configure the new XML Data Target, we will use the Bookstore.xsd sample located in C:\Program Files\Liquid Technologies\Liquid XML Studio 2017\Examples\BookStore, the output file will be written to C:\Program Files\Liquid Technologies\Liquid XML Studio 2017\Examples\BookStore\HorrorBooks.xml.

You should supply an output file for it to write its output to. This can be done within the transform itself, but typically you would do this when creating the XML Data Target.

Once you have completed the wizard you will see the new component on the canvas. You will notice its inputs are taken from the structure of the XSD schema you provided as an input.

XML Writer

Now we can think about where to get our input data from. The XML Data Source component will allow us to read data from an XML file. Again we can create one by dragging an XML Data Source from the Component Palette. The XML Data Source component also gets its meta data (i.e. a description of the input document) from an XML Schema (or can be inferred from XML documents). Again we will use the Bookstore.xsd in this example. The reader also needs an input data file, we will use C:\Program Files\Liquid Technologies\Liquid XML Studio 2011\Examples\BookStore\BookStoreSample.xml.

The XML Data Source requires an input filename, this can be done within the transform itself using the Filename input connector, but typically you would set it when creating the XML Data Source in the wizard.

To start with we can connect all the input and output connection points together, this will mirror the input data in the output (not much of a transform, be we can see how things work).

The connection point hit area includes its text, so its easier to drag the connection point by clicking and dragging from its text

Data Mapper Pass Through

Pressing Shift-F5 (Execute) will execute the transform and display the results.

Pressing F5 (Debug) will start the debugger, we can then step through the transform seeing the way the transform is executed and watching the data move around. This gives some incite into how the transformation engine works, and understanding unexpected results easier to get to grips with.

Debugging

Now we can look at making the transform do something useful, we will apply a simple filter to the data, only selecting books in the "Horror" genre.

Drag a Filter onto the canvas (in the "Set" section) and connect its "Nodes" input to the "book" output, this gives the Filter its context, i.e. its operating within the context of each book. Connect the Filters "Result" output back to the "book" input connection point on the output component. If the Filters "bool" input receives a true value then the current book object will be output via the "Result", otherwise its discarded.

Drag on an Equals component (in the Equality section) and connect its "result" to the filters "bool" input. Connect one of its inputs to the XML Sources "genre" output.

Drag on a Constant component (in the Constant section) set its type to be String and its value to be Horror (right click on it and select "Properties"). Connect its "Value" connector to the other input on the Equals component.

Filter

When we run the transform it now filters the input books only returning ones that contain a genre which equals "Horror".

 

The transform output Copy Code
<bookstore xmlns="https://www.liquid-technologies.com/sample/bookstore">
    <book price="4.99" publicationdate="2008-10-20T00:00:00Z" ISBN="978-0747596837">
        <title>The Graveyard Book</title>
        <author>
            <first-name>Neil</first-name>
            <last-name>Gaiman</last-name>
        </author>
        <genre>Horror</genre>
    </book>
</bookstore>

 

Lets look at what we have created, and how it runs. First off start the debugger (F5  Debug) and step through the transform (F-11 Step into) you'll notice that things run from right to left. Values are requested from a component, which triggers the component to pull values from its child inputs.