Tip:
Highlight text to annotate it
X
[ MUSIC ]
Hello, and welcome to this video tutorial on how to use the IBM Graphical Data Mapper.
I'm going to show you how to create a graphical map
that will transform data between different formats.
These can include XML data as well as text and binary formats
that have been modeled using the DSDL base description standard.
In this demonstration, I'm using the Graphical Data Mapper from within IBM integration bus.
Here I have an integration flow.
That is my mapping mode to transform the format of data from a file.
Double clicking on the mapping mode the first time will launch a wizard to create a new map.
I give the map a name and click next.
Next, I select the element from the skin map
that represents the overall structure of the input and output formats.
We'll then select the domain or parser that will serialize the output structure.
We should use the default XML that's IBM integration bus.
Also supports general text and binary formats including industry standard formats.
Click finish, and the map will be created.
Let's look at the map.
On the lefthand side there's a tree that represents a structure
of the inputs or source document.
Up on the righthand side, we have a tree that represents the output, the target.
At each level in the hierarchy, you can see the element name, a value type
and the counts indicator that tells us whether the element is optional or [can repeat].
Now going to create some mappings that differ in the transformation.
The general methodology with this mapper is to start with top-level structures
and then work our way down the hierarchy dividing the task up into smaller nested maps.
We'll start by mapping the [style list] input structure to the purchase list out codes.
Click on the source element and drag target.
A transform bit is created, as represented by the blue box in the middle.
The transform has a type.
This one is called for each, which means that it's going to loop
over the input repeating structure to produce the output repeating structure.
The map I choose is the most appropriate transform type depending
on the input and output elements.
To map the contents of the structure, we click the link in the transform box.
This takes us into the structure and shows it as a new nested map in the editor.
Drag and drop the invoice to the statement.
This creates another for each transform since the source
and target are both potentially repeating.
Click into the transform to continue mapping.
Here we can start mapping some values into elements and attributes.
The template transform type is the assigned.
This is used to assign a literal value into the target.
The value is entered into the properties tab below.
Click again for the type attribute.
Customer is a structure that contains a number of elements.
A good practice in the GDM mapper when mapping structures in the input for structures
and the output to use the local transform, which is a simple container that holds a nested map,
a bit like a for each without any repeating.
In this case, though, we only have a few child elements, so we'll map directly into them.
Let's start with the name, which is taken from the serial name element in the output.
Notice that we can drag from right to left, as well as left to right.
It makes no difference.
This has created a new transform for us, which will take the value from the input element
and assign it to the target element.
Do the same with balance.
Initials is slightly more complicated.
The target element, initials, in the plural, is a single nonrepeating element.
Source initial, in the singular, is a repeating element,
with each element containing one initial.
We'll want to join these together.
When we map these, it chooses a move.
It gives us a warning that the source is potentially repeating and the target isn't.
It also suggests a quick fix of setting the [INAUDIBLE] index property to one.
But we don't want to do this.
We want to join all of the input values together into a single target string.
So, we change the transform type by clicking the down arrow next to the transform name.
We have a large library of built-in functions available.
Most of these are from the standard XPath function library.
The function we want is string join.
The properties editor allows us to customize the parameters that are given to this function.
Defaults are good enough for us here.
The next part is to map the purchases structure.
This contains a number of articles which will map
from the repeating in item structure on the inputs.
[INAUDIBLE] nested map to map contents.
You've seen how easy it is to copy values directly from input to outputs.
We've also seen that we can use built-in functions to modify or combine values.
However, there are times when we want to write an expression.
For example, to do numerical manipulation.
You might want to multiply the prompt value by some factor.
And I need a language to express that.
The language that we provide for this is XPath 2.0,
which is a [INAUDIBLE] based expression language designed precisely for manipulating this type
of hierarchical schema based data.
In order to do XPath expressions, I select the custom XPath transform type.
I can then type my expression in the properties editor.
In this case, we want to apply a discount.
So, we'll multiply the price by [INAUDIBLE].
It may be that we only want to apply this discount logic
if we have a discount code in the input.
All of the transform types in GDM have a standard property called condition.
The transform will only get invoked if the condition evaluates to true.
The language that is used to express this condition is XPath 2.
Pressing control space brings up the content assist for XPath.
It shows us the variables that are available for use in our expression.
The variables represent the inputs to the transform.
We want to make reference for the code input element to see
if there is one with a discount value.
To do this, we simply drag in a second input.
Now see the code is available as an XPath and reference variable,
and we can use that in our expression.
This transform will only get run if there exists the code element whose value equals discounts.
If there isn't, the transform won't get done and the target element won't get created,
and the whole transform has a condition, a yellow diamond that creates the transform box.
I'll bring the mouse over this, display the condition.
In this case we want the target to be created if the condition is false.
But with a simple move relevant of discount by clicking
on additional transform, a couple of icons pop up.
One of them is labeled add else.
Clicking on this refactors our map slightly.
It gives us an if-else conditional block
and it pushes the original XPath transform down into the method map.
It also gives us an else transform which gets invoked if the condition evaluates to false.
I will drag the price element into the else block,
and the results of the else block will go into the cost target.
We then click into the else in order to do the simple move mapping.
The last bit to map in this example is the amount element.
This is a switch element with attribute content.
You can't see [INAUDIBLE] in a simple move.
The element value, we want to calculate the total accumulative value
of the price times the quantity of each item in the input.
This is something that is very natural to do in XPath 2.
It can be achieved using this expression.
It completes all the mappings we want to configure in this example.
I hope it gives you a basic idea of the techniques involved
in transforming data between different formats.
Thank you for taking the time to...