Version 1.1 by eMagiz on 2022/05/05 10:04

Show last authors
1 {{html wiki="true"}}
2 <div class="ez-academy">
3 <div class="ez-academy_body">
4
5 <div class="doc">
6
7
8
9 = Handling multiple namespaces =
10
11 Sometimes you encounter definitions of external systems that refer to other definitions that are in different namespaces. As a result, the XML message you need to send or receive contains multiple namespaces. As one definition in eMagiz (and in XSD) can only include one namespace and eMagiz does not support references to other definitions, you need to have the ability to transform from one (or zero) namespace to multiple and vice versa. In this microlearning, we will discuss both variants to provide insight on how to achieve this.
12
13 Should you have any questions, please get in touch with academy@emagiz.com.
14
15 * Last update: October 25th, 2021
16 * Required reading time: 6 minutes
17
18 == 1. Prerequisites ==
19
20 * Advanced knowledge of the eMagiz platform
21
22 == 2. Key concepts ==
23
24 This microlearning focuses on handling multiple namespaces.
25
26 With namespace, we mean a set of uniquely named elements and attributes in an XML document.
27
28 To achieve this, we need an intermediate step:
29
30 * Remove namespaces (when receiving the message)
31 * Adding namespaces (when sending the message)
32
33
34
35 == 3. Handling multiple namespaces ==
36
37 Sometimes you encounter definitions of external systems that refer to other definitions that are in different namespaces. As a result, the XML message you need to send or receive contains multiple namespaces. As one definition in eMagiz (and in XSD) can only include one namespace and eMagiz does not support references to other definitions, you need to have the ability to transform from one (or zero) namespace to multiple and vice versa. In this microlearning, we will discuss both variants to provide insight on how to achieve this.
38
39 To achieve this, we need an intermediate step:
40
41 * Remove namespaces (when receiving the message)
42 * Adding namespaces (when sending the message)
43
44 === 3.1 Remove namespaces ===
45
46 Before we can validate our incoming message with the tooling of eMagiz, we need to remove all the namespaces from the message. Luckily there is a custom transformation available in the eMagiz store that removes all namespaces from a message. Search for remove namespace in the eMagiz store. This custom transformation searches for all namespaces and removes them, including their prefixes. See below for an example of how this will work for you.
47
48 This XSLT transformer will use a custom resource as attached and configured to perform the following actions:
49
50 1. Remove all namespaces in your XML Message. Example:
51
52 <?xml version="1.0" encoding="UTF-8"?>
53
54 <sys:root_element xmlns:sys="http://www.emagiz.com/ns/es-store/cdm/1.0/">
55 <sys:envelope>
56 <sys:messagetype>O2C_DESADV</sys:messagetype>
57 </sys:envelope>
58 </sys:root_element>
59
60 will become
61
62 <root_element>
63 <envelope>
64 <messagetype>O2C_DESADV</messagetype>
65 </envelope>
66 </root_element>
67
68 2. Keynotes
69 a. This will lead to an attribute name clash if an element contains two attributes with the same local name but different namespace prefix b. Nodes that cannot have a namespace are copied as such
70
71 === 3.2 Add namespaces ===
72
73 Adding namespaces is a two-part process within eMagiz currently. To make this work, you should prepare your definition in eMagiz by adding prefixes to each entity and attribute (based on which namespace they should be sent). As a result, you get a specific prefix for each particular namespace. After doing this, you can use a custom transformation (available in the eMagiz store) to transform these prefixes to the correct namespaces. Search for adding namespaces in the eMagiz store to get access to the custom transformation.
74
75 For more context on this solution, check out the store documentation and this Q&A interaction:
76
77 * https://my.emagiz.com/p/question/172825635700350785
78
79 ===== Practice =====
80
81 == 4. Assignment ==
82
83 Check out whether removing or adding namespace is used within your project.
84 This assignment can be completed within the (Academy) project you created/used in the previous assignment.
85
86 == 5. Key takeaways ==
87
88 * With custom functionality, you can add and remove namespaces
89 * You can use the eMagiz store for this
90
91
92
93 == 6. Suggested Additional Readings ==
94
95 If you are interested in this topic and want more information, please read the help text provided by eMagiz.
96
97 == 7. Silent demonstration video ==
98
99 As this is more of theoretical microlearning, there is no video accompanying the microlearning.
100
101 </div>
102 </main>
103 </div>
104 </div>
105
106 {{/html}}