Changes for page Data Exchange
Last modified by Erik Bakker on 2024/09/05 14:00
From version 8.1
edited by Erik Bakker
on 2022/07/26 12:49
on 2022/07/26 12:49
Change comment:
There is no comment for this version
To version 6.1
edited by Erik Bakker
on 2022/07/26 08:31
on 2022/07/26 08:31
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - ImageTransformations1 +expert-create-your-transformations-xpath-expert - Content
-
... ... @@ -1,5 +1,5 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 - Inmost cases,you will transformXMLmessagestoherXMLmessages,oryou willtransformJSONorEDImessagesin anotheroftheseformats.However,sometimesyouwanttoperformransformation.With thisimagetransformationyoucantransformimagesins toanotherformat(i.e.png).Thiscan comehandywhenyouwantdize the imageformat beforeusing itfurtherdownstreaminyourbusinessapplication(s).2 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]]. In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] if you need a refresher on that. In the [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.Create your transformations.advanced-create-your-transformations-xpath-advanced.WebHome||target="blank"]] that followed, we built upon that knowledge and looked at some concrete, practical examples that could be useful in your project. In this microlearning, we will wrap the concept of XPath by looking at three complex XPath alternatives that are sometimes needed when dealing with messages in eMagiz. 3 3 4 4 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 5 5 ... ... @@ -6,33 +6,66 @@ 6 6 == 1. Prerequisites == 7 7 8 8 * Expert knowledge of the eMagiz platform 9 +* [[XPath Basic>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]] 10 +* [[XPath Intermediate>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] 11 +* [[XPath Advanced>>doc:Main.eMagiz Academy.Microlearnings.Advanced Level.Create your transformations.advanced-create-your-transformations-xpath-advanced.WebHome||target="blank"]] 9 9 13 + 10 10 == 2. Key concepts == 11 11 12 -This microlearning focuses on performingimagetransformationsin eMagiz.16 +This microlearning focuses on more complex XPath operations. 13 13 14 -With imagetransformation, we meantransforming the raw datathatrepresents animage toanotherimageformat.18 +With XPath Advanced, we mean learning that XPath options are complex but could benefit you in your daily work. 15 15 16 -* Read the helptext of the component to understand which formats are supported 17 -* Ensure the input image is supplied in the correct format 18 -* Ensure you wrap the output image in something if you want to do additional transformations on the data further downstream 20 +Some of the more complex XPath options are: 19 19 20 -== 3. Image Transformation == 22 +* dateTime calculation 23 +* Filter list 24 +* XPath on JSON 25 +* SpEL notation for XPath 21 21 22 -In most cases, you will transform XML messages to other XML messages, or you will transform JSON or EDI messages in another of these formats. However, sometimes you want to perform an image transformation. With this image transformation you can transform images in certain formats to another format (i.e. png). This can come in handy when you want to standardize the image format before using it further downstream in your business application(s). 23 23 24 -Before we dive into the specifics of how to configure this let us first consider the following: 25 25 26 -* Read the helptext of the component to understand which formats are supported 27 -* Ensure the input image is supplied in the correct format 28 -* Ensure you wrap the output image in something if you want to do additional transformations on the data further downstream 29 +== 3. XPath Advanced == 29 29 30 - {{warning}}Thefocusofthis microlearningliesontheimagetransformer component.Ensuringthat theinputis usefulandthe outputfitstheder oftherocessishighlydepending on the usecase andwilltherefore notbescussed in this microlearning{{/warning}}31 +Within the crash course, we already explained XPath conceptually. In that same microlearning, we also looked at some more uncomplicated cases of using XPath within your transformation. If you need to brush up on that knowledge, please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-create-transformation-xpath-basic.WebHome||target="blank"]]. In the intermediate microlearning on this subject, we built upon that knowledge. Please check out this [[microlearning>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.Create your transformations.intermediate-create-your-transformations-xpath-intermediate.WebHome||target="blank"]] if you need a refresher on that. In this microlearning, we will build upon that knowledge and look at some concrete, practical examples that could be useful in your project. 31 31 32 - When turning totheCreate phaseofeMagiz, we needto open theflow and enter "Start Editing"modeto add thecomponent we need. For example,intheleftpanel, you canearchfor "Image". This will yield the followingresult.33 +Some of the more complex XPath options are: 33 33 34 -[[image:Main.Images.Microlearning.WebHome@expert-create-your-transformations-image-transformation-image-transformation-component.png]] 35 +* dateTime calculation 36 +* Filter list 37 +* XPath on JSON 38 +* SpEL notation for XPath 35 35 40 +=== 3.1 dateTime calculation === 41 + 42 +Sometimes we see that a dateTime calculation is needed within a transformation to determine a specific action. As these calculations are not natively supported within the eMagiz platform, you need to use XPath's functionality to calculate the new valid date (or dateTime). 43 + 44 +The XPath standard offers several functions to calculate with dateTime values. The two most used options are dayTimeDuration and yearMonthDuration. With the help of the dayTimeDuration, you can add, subtract, multiple, or divide seconds, minutes, hours, and days regarding the original value. The yearMonthDuration works similarly but then for months and years. An example of such an XPath is: <xsl:value-of xmlns:xs="http://www.w3.org/2001/XMLSchema" select="CDM:StartDate + xs:dayTimeDuration('P1D') * xs:yearMonthDuration('P1M')"/>. In this example, XPath adds one day and subtracts one month from the input date. Note that making this work requires the additional namespace to be defined. Therefore you need a custom snippet within your transformation or a custom transformation to make this work. Furthermore, note that the P1D and P1M could also be filled with the help of parameters to make them dynamic in nature. 45 + 46 +Some examples that we saw during the years: 47 + 48 +* https://my.emagiz.com/p/question/172825635700358186 49 +* https://my.emagiz.com/p/question/172825635700352588 50 + 51 +=== 3.2 Filter list === 52 + 53 +Sometimes you have a large message which contains a certain list within it. However, logic dictates that you can only send the message if at least one entry in the list for which attribute A is filled and attribute B equals type C. To make that happen in XPath, we first need to navigate to the list within the message. As we previously learned, there are two options to do so. One is to use // to navigate to the entity somewhere in the tree directly. The other is to start at the root and walk the tree from there. In this example, we use the latter. That results in the following XPath example: /root/list[attributeB = 'type C']/attributeA !=''. With this XPath, you filter the list on the specified check and subsequently check whether one of those entries that remains has an attributeA which is filled in. 54 + 55 +=== 3.3 XPath on JSON === 56 + 57 +With the release of build number .50, we expanded our offering on JSON messages to resemble much of the functionality we previously offered for XML messages. As a result, you can use XPath expressions on JSON messages within the following components (related to XPath): 58 + 59 +* XPath header enricher 60 +* XPath transformer 61 +* XPath router 62 + 63 +To activate the functionality, simply link the JSON source factory support object to one of these components to achieve the desired result. For more information, check out: https://emagiz.github.io/docs/release-notes/build50. 64 + 65 +=== 3.4 SpEL notation for XPath === 66 + 67 +Sometimes you want to perform an XPath operation but store the header via a standard message header enricher component. As a result, you need a valid SpEL expression to help you in this cause. To do so, you need to know the correct notation for an XPath expression when using the SpEL language. An example of the correct notation is: #xpath(payload,'/root/entity/attribute') 68 + 36 36 == 4. Assignment == 37 37 38 38 Check out which of the XPaths we have discussed today can be found within your project. ... ... @@ -40,19 +40,18 @@ 40 40 41 41 == 5. Key takeaways == 42 42 43 -Some of the verycomplex XPath options are:76 +Some of the more complex XPath options are: 44 44 45 -* matches 46 -* replace 47 -* tokenize 78 +* dateTime calculation 79 +* Filter list 80 +* XPath on JSON 81 +* SpEL notation for XPath 48 48 49 49 == 6. Suggested Additional Readings == 50 50 51 -If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following link s:85 +If you are interested in this topic and want more information on it, please read the help text provided by eMagiz and read more information on the following link: 52 52 53 -* http://www.xsltfunctions.com/xsl/fn_matches.html 54 -* http://www.xsltfunctions.com/xsl/fn_replace.html 55 -* http://www.xsltfunctions.com/xsl/fn_tokenize.html 87 +* https://www.w3schools.com/xml/xpath_intro.asp 56 56 57 57 == 7. Silent demonstration video == 58 58