Wiki source code of Transformation XML to XML

Last modified by Erik Bakker on 2024/08/19 22:10

Show last authors
1 {{container}}{{container layoutStyle="columns"}}(((
2
3 In this microlearning, we’ll explore the transformation capabilities within eMagiz, focusing on the simple yet essential task of transforming XML to XML. While basic message mappings in Design might handle straightforward cases, more complex transformations require additional tools available in the Create phase. We’ll walk through the options you have for customizing your data transformations, ensuring that your source messages convert correctly into target messages. Let’s get started!
4
5 Should you have any questions, please contact [[academy@emagiz.com>>mailto:academy@emagiz.com]].
6
7 == 1. Prerequisites ==
8
9 * Basic knowledge of the eMagiz platform
10
11 == 2. Key concepts ==
12
13 This microlearning focuses on the transformation in Create (XML to XML).
14
15 With transformation we mean: Transforming the data in such a manner that the source message will lead to a valid target message
16
17 == 3. Transformation XML to XML ==
18
19 In the Create phase of eMagiz, you can build upon the message mapping made in Design.
20 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
21
22 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--flow-editor-overview.png]]
23
24 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.
25
26 Note that the transformation option is only available for flows that are set up for processing (i.e. transforming) data:
27
28 * **Messaging**: Onramp and Offramp
29 * **API Gateway**: Exit gate
30 * **Event Streaming**: The event processor
31
32 When you select the Transformation option eMagiz will show you what you have drawn while executing your message mapping in Design.
33
34 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--create-transformation.png]]
35
36 The above picture should have a familiar feeling as it closely resembles what we have determined while doing our message mapping.
37 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.
38 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.
39
40 Before we delve into the specific options let us first enter Start Editing mode.
41
42 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--start-editing-mode.png]]
43
44 === 3.1 Filter ===
45
46 As you can see, eMagiz already added a yellow trapezium (a turned one at least). This icon indicates a filter.
47 As you can see the Description attribute is optional (written in Italic) therefore we only want to fill the Description
48 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
49
50 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--filter-attribute-explanation.png]]
51
52 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.
53 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.
54
55 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--editing-options-entity-level.png]]
56
57 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.
58
59 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-options.png]]
60
61 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.
62 This makes sure that only Design entities in the input with an ID with content ID-4 will be transformed to the target message.
63
64 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-solution.png]]
65
66 To visually tell you and others that a filter has been added the yellow trapezium will appear.
67
68 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--entitity-filter-result.png]]
69
70 === 3.2 Transform ===
71
72 The second option at your disposal to ensure that you generate a valid target message is to transform.
73 Transformation actions are visually represented as a blue rectangle.
74
75 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation.png]]
76
77 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
78
79 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation-options.png]]
80
81 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.
82 Note, that based on the data type of the input attribute other options will be presented to you by eMagiz.
83
84 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.
85
86 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-transformation-option-filled-in.png]]
87
88 To visually tell you and others that a transformation has been added the blue rectangle will appear.
89
90 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--transformation-result.png]]
91
92 === 3.3 Static Input ===
93
94 The third option at your disposal to ensure that you generate a valid target message is to enter a static input.
95 Static input actions are visually represented as a green circle and are only selectable for attributes without a source attribute.
96
97 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input.png]]
98
99 As you might well remember we have added a note on this attribute telling us how we should fill this value.
100 So let's take a look at the note to see what it said exactly. To read it hover over the note icon
101
102 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-read-note.png]]
103
104 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.
105 First, select the option static input (green circle). This will lead you to the following pop-up
106
107 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-pop-up.png]]
108
109 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.
110
111 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-static-input-pop-up-solution.png]]
112
113 To visually tell you and others that a static input has been added the green circle will appear.
114
115 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--static-input-result.png]]
116
117 === 3.4 Conditional ===
118
119 The fourth option at your disposal to ensure that you generate a valid target message is to enter a conditional.
120 Conditional actions are visually represented as a yellow diamond.
121
122 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional.png]]
123
124 A conditional is very similar to a filter option.
125 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.
126
127 To get what I mean let us take a look at the pop-up for a conditional
128
129 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional-pop-up.png]]
130
131 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.
132 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
133
134 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--attribute-conditional-pop-up-filled-in.png]]
135
136 To visually tell you and others that a conditional has been added the yellow diamond will appear.
137
138 [[image:Main.Images.Microlearning.WebHome@crashcourse-platform-create-transformation-xml-to-xml--conditional-result.png]]
139
140 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.
141 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.
142
143 == 4. Key takeaways ==
144
145 * eMagiz provides you with several out of the box options to correctly transform your data to end up with a valid target message
146 * All options have their unique use case
147
148 == 5. Suggested Additional Readings ==
149
150 * [[Crash Course (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Novice.WebHome||target="blank"]]
151 ** [[Crash Course Platform (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.WebHome||target="blank"]]
152 *** [[Data Type Transformations (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-data-type-transformations||target="blank"]]
153 *** [[Transformation - XPath Basic (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic||target="blank"]]
154 * [[Novice (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Novice.WebHome||target="blank"]]
155 ** [[Create your transformations (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.WebHome||target="blank"]]
156 *** [[Transformation - JSON to XML (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.novice-create-your-transformations-json-to-xml||target="blank"]]
157 *** [[Transformation - XML to JSON (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.novice-create-your-transformations-xml-to-json||target="blank"]]
158 *** [[Enumerations (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.novice-create-your-transformations-enumerations||target="blank"]]
159 *** [[XSLT Parameters (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.novice-create-your-transformations-xslt-parameters||target="blank"]]
160 *** [[XSLT Snippet (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Novice.Create your transformations.novice-create-your-transformations-xslt-snippet||target="blank"]]
161 * [[Intermediate (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.WebHome||target="blank"]]
162 ** [[Create your transformations (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.WebHome||target="blank"]]
163 *** [[Transformation - XPath Intermediate (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate||target="blank"]]
164 *** [[Default eMagiz XSLT Functions (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-emagiz-xslt-functions||target="blank"]]
165 *** [[Transformation - Grouping (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-grouping.WebHome||target="blank"]]
166 * [[Expert (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Expert Level.WebHome||target="blank"]]
167 ** [[Create your transformations (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Expert Level.Create your transformations.WebHome||target="blank"]]
168 *** [[XPath Expert (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Expert Level.Create your transformations.expert-create-your-transformations-xpath-expert||target="blank"]]
169 * [[Transformation (Search Result)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=1%2FMain.eMagiz+Academy.&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22transformation%22||target="blank"]]
170
171
172 )))((({{toc/}}))){{/container}}{{/container}}