Wiki source code of Transformation XML to XML

Last modified by Erik Bakker on 2023/01/24 15:09

Show last authors
1 {{container}}{{container layoutStyle="columns"}}(((
2
3 A central part of the eMagiz platform is the ability to transform data from one structure to another structure.
4 As you can remember from our microlearning on message mappings this process starts in Design.
5
6 It would be great if drawing a line, saying that a is the input for b would always be enough. Sadly though that is not always the case (the easiest example is the set as a mapped option).
7 For all cases where only drawing a line does not suffice you can alter the transformation between a and b with the help of the Create Transformation.
8
9 Within Create you can transform between multiple message formats. In this microlearning, we will focus on the simplest one, XML to XML.
10
11 Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]].
12
13 == 1. Prerequisites ==
14
15 * Basic knowledge of the eMagiz platform
16
17 == 2. Key concepts ==
18
19 This microlearning focuses on the transformation in Create (XML to XML).
20
21 With transformation we mean: Transforming the data in such a manner that the source message will lead to a valid target message
22
23 == 3. Transformation XML to XML ==
24
25 In the Create phase of eMagiz, you can build upon the message mapping made in Design.
26 When you open your flow by double-clicking on it (or opening it via the context menu) you will see the following visual representation of the flow itself
27
28 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--flow-editor-overview.png]]
29
30 More on what this overview represents later on in this module. For now, let us turn our attention to the Transformation part of a flow.
31
32 Note that the transformation option is only available for flows that are set up for processing (i.e. transforming) data:
33
34 * **Messaging**: Onramp and Offramp
35 * **API Gateway**: Exit gate
36 * **Event Streaming**: The event processor
37
38 When you select the Transformation option eMagiz will show you what you have drawn while executing your message mapping in Design.
39
40 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--create-transformation.png]]
41
42 The above picture should have a familiar feeling as it closely resembles what we have determined while doing our message mapping.
43 However, you can also see some differences between the two. In Create you have several options at hand to correctly transform the data while being in Start Editing Mode.
44 Below we will discuss each of these options briefly. Apart from the set of generic options, a lot more can be done but we will leave that out of the discussion for now.
45
46 Before we delve into the specific options let us first enter Start Editing mode.
47
48 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--start-editing-mode.png]]
49
50 === 3.1 Filter ===
51
52 As you can see, eMagiz already added a yellow trapezium (a turned one at least). This icon indicates a filter.
53 As you can see the Description attribute is optional (written in Italic) therefore we only want to fill the Description
54 attribute in the target message when the Description field in the source message exists (meaning the tag exists in the message) and is not empty
55
56 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--filter-attribute-explanation.png]]
57
58 Apart from filtering on attributes, you can also filter on entities. For example, in this case, I could say that I only want a Design entity if the ID is ID-4.
59 This you can easily do by adding a filter on the target entity called Design. To do so press the + icon in front of this entity and select the yellow filter icon.
60
61 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--editing-options-entity-level.png]]
62
63 As a result, you will be presented with the following pop-up. Here you can choose from the input attributes that fall under the entity from which you have drawn your line in the message mapping.
64
65 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-options.png]]
66
67 This solution works perfectly for us in this example case. Select the ID as input attribute, leave it equal true as it is and fill in ID-4.
68 This makes sure that only Design entities in the input with an ID with content ID-4 will be transformed to the target message.
69
70 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-solution.png]]
71
72 To visually tell you and others that a filter has been added the yellow trapezium will appear.
73
74 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-result.png]]
75
76 === 3.2 Transform ===
77
78 The second option at your disposal to ensure that you generate a valid target message is to transform.
79 Transformation actions are visually represented as a blue rectangle.
80
81 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation.png]]
82
83 For example, let us say that we only want to have the first three characters of the input attribute ID on the CrashCourse level. To do so we select the transform option and enter the following pop-up
84
85 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation-options.png]]
86
87 Here we see several options that we can use. As the input is a string and we want the first three characters we can use the substring option.
88 Note, that based on the data type of the input attribute other options will be presented to you by eMagiz.
89
90 In this case, we fill in 1 as the start position and 3 for the length. This will ensure that eMagiz will only place the first three characters of the ID it receives in the target message.
91
92 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation-option-filled-in.png]]
93
94 To visually tell you and others that a transformation has been added the blue rectangle will appear.
95
96 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--transformation-result.png]]
97
98 === 3.3 Static Input ===
99
100 The third option at your disposal to ensure that you generate a valid target message is to enter a static input.
101 Static input actions are visually represented as a green circle and are only selectable for attributes without a source attribute.
102
103 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input.png]]
104
105 As you might well remember we have added a note on this attribute telling us how we should fill this value.
106 So let's take a look at the note to see what it said exactly. To read it hover over the note icon
107
108 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-read-note.png]]
109
110 Okay, now that we know again what we wanted to fill in let us take you through the steps of how you can make this happen.
111 First, select the option static input (green circle). This will lead you to the following pop-up
112
113 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-pop-up.png]]
114
115 As the note states, we always want to fill in the string value: Microlearning eMagiz Academy. In other words, we need to fill in a constant with this value. That should look as follows.
116
117 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-pop-up-solution.png]]
118
119 To visually tell you and others that a static input has been added the green circle will appear.
120
121 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--static-input-result.png]]
122
123 === 3.4 Conditional ===
124
125 The fourth option at your disposal to ensure that you generate a valid target message is to enter a conditional.
126 Conditional actions are visually represented as a yellow diamond.
127
128 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional.png]]
129
130 A conditional is very similar to a filter option.
131 The only difference is that when a filter determines that you are not on the list you won't get in whereas the conditional will treat you as some pre-defined constant.
132
133 To get what I mean let us take a look at the pop-up for a conditional
134
135 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional-pop-up.png]]
136
137 As you can see, there are a lot of similarities between the filter and the conditional. The only difference is that the conditional provides you with an escape opportunity.
138 So let us define that escape. In this case, we want that whenever the ID does not exist (or is empty) the value ID-1 should appear. The result will look like this
139
140 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional-pop-up-filled-in.png]]
141
142 To visually tell you and others that a conditional has been added the yellow diamond will appear.
143
144 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--conditional-result.png]]
145
146 For those of you paying attention, it should be clear that the way I have configured the examples there is no way that the conditional will ever lead to an output of ID-1.
147 Having said that the above examples give a good indication of the various options you have at your disposal to transform messages without having to possess complex programming skills.
148
149 == 4. Key takeaways ==
150
151 * eMagiz provides you with several out of the box options to correctly transform your data to end up with a valid target message
152 * All options have their unique use case
153
154 == 5. Suggested Additional Readings ==
155
156 If you are interested in this topic and want more information on it please read the help text provided by eMagiz.
157 )))((({{toc/}}))){{/container}}{{/container}}