cancel
Showing results for 
Search instead for 
Did you mean: 

Payload Transformation in CPI

0 Kudos

Hello Community,

I want to transform the structure of a Payload like below using an XSLT Transformation or any other way.

Original Payload: (Many Root nodes with the same MessageHeader node)

<root>
<MessageHeader>
...
</MessageHeader>
<RequestMessage>
<MessageHeader/>
...
<RequestMessage>
</root>
<root>
<MessageHeader>
...
</MessageHeader>
<RequestMessage>
<MessageHeader/>
...
<RequestMessage>
</root>

Transformed Payload: One Root Node with One Message Header Node and Many RequestMessage Nodes

<root>
<MessageHeader>
...
</MessageHeader>
<RequestMessage>
<MessageHeader/>
...
<RequestMessage>
<RequestMessage>
<MessageHeader/>
...
<RequestMessage>
</root>

Could you help me please?

Thanks,

Nadir

Accepted Solutions (0)

Answers (8)

Answers (8)

0 Kudos

Hello everyone,

Thanks for your help !

I finally did it with the XSLT below:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="MainRoot">
<root>
<xsl:copy-of select="root[1]/MessageHeader"/>
<xsl:for-each select="root">
<xsl:copy-of select="RequestMessage"/>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
Sriprasadsbhat
Active Contributor
0 Kudos

Hello Nadir,

Below should work for you.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="@* | node()">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="MainRoot">
          <root>
		<xsl:for-each select="root">						
				<xsl:apply-templates select="MessageHeader"/>
				<xsl:copy-of select="RequestMessage"/>						
		</xsl:for-each>
         </root>
	</xsl:template>
	<xsl:template match="MessageHeader[ID = following::MessageHeader/ID]">
		<xsl:copy-of select="MessageHeader"/>
	</xsl:template>  
</xsl:stylesheet>

Regards,

Sriprasad Shivaram Bhat

0 Kudos

Hi sriprasadshivaramabhat

This is what i am getting from your XSLT:

<root>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
         <Name>New Name</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
   <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
         <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
         <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
   </MessageHeader>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
         <Name>New Name 2</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
</root>

The root/MessageHeader node should be before all RequestMessage Nodes.

Thanks !

Regards,

Nadir

0 Kudos

Hi sriprasadshivaramabhat

Sorry for the confusion. To simplify, please take into account the situation below:

Incoming Payload:

<MainRoot>
<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089126</ID>
	<Name>New Name</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>
<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089127</ID>
	<Name>New Name 2</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>
</MainRoot>

Transformed Payload by your first XSLT:

<MainRoot>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
         <Name>New Name</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
   <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
         <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
         <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
   </MessageHeader>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
         <Name>New Name 2</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
</MainRoot>

Expected Payload:

<root>
   <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
         <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
         <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
   </MessageHeader>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
         <Name>New Name</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
         <Name>New Name 2</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
</root>

I hope it is more clear.

Thanks a lot.

Regards,

Nadir

Sriprasadsbhat
Active Contributor
0 Kudos

Dear Nadir,

I am completely confused with your Input Structure and Output structure.As per your earlier thread input structure was having multimap:Message tag and whatever you have pasted now has nothing.Please share the correct input and output structure you are looking for to get correct response from community.

Regards,

Sriprasad Shivaram Bhat

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Nadir,

Below should work and I would suggest you to tweak to code & try out different possibilities.

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://www.w3.org/1999/XSL/Transform" xmlns:multimap="http://sap.com/xi/XI/SplitAndMerge"  xmlns:ns1="http://sap.com/xi/SAPGlobal20/Global" exclude-result-prefixes="multimap ns1">
	<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="/|comment()|processing-instruction()">
		<xsl:copy>
			<xsl:apply-templates />
		</xsl:copy>
	</xsl:template>
	<xsl:template match="*">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*|node()" />
		</xsl:element>
	</xsl:template>
	<xsl:template match="@*">
		<xsl:attribute name="{local-name()}">
			<xsl:value-of select="." />
		</xsl:attribute>
	</xsl:template>
	<xsl:template match="multimap:Messages/multimap:Message1" >
		<Root>
			<xsl:for-each-group select="ns1:LeanLeadReplicationBulkReplicateRequest" group-by="MessageHeader/ID">
				<Records>
					<xsl:for-each select="current-group()">
						<xsl:apply-templates select="MessageHeader"/>
						<xsl:copy-of select="LeanLeadReplicateRequestMessage"/>
					</xsl:for-each>
				</Records>
			</xsl:for-each-group>
		</Root>
	</xsl:template>
	<xsl:template match="MessageHeader[ID = following::MessageHeader/ID]">
		<xsl:copy-of select="MessageHeader"/>
	</xsl:template>
	<xsl:template match="multimap:Messages">        
		<xsl:apply-templates />        
	</xsl:template>
</xsl:stylesheet>

Regards,
Sriprasad Shivaram Bhat

0 Kudos

Hello sriprasadshivaramabhat

Thanks for your answer, I have no idea how to work on an XSLT.

It did not work, same as my above answer.

Please see my comment from yesterday, it is just a position matter for now:

Transformed Payload by your code:

<root>
<RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
         </RequestMessageInformation>
</RequestMessage>
<MessageHeader>
</MessageHeader>
<RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
         </RequestMessageInformation>
</RequestMessage>
</root>

Expected Payload:

<root>
<MessageHeader>
</MessageHeader>
<RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
         </RequestMessageInformation>
</RequestMessage>
<RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
         </RequestMessageInformation>
</RequestMessage>
</root>

Regards,

Nadir

yatanveersingh
Active Participant
0 Kudos

Hi Nadir,

for the below input payload

<root>
  <root>
    <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
        <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
        <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
    </MessageHeader>
    <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
        <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
        <Name>New Name</Name>
        <PriorityCode>3</PriorityCode>
        <ProcessingDatePeriod>
          <StartDate>2020-08-14</StartDate>
          <EndDate>2020-08-21</EndDate>
        </ProcessingDatePeriod>
        <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
    </RequestMessage>
  </root>
  <root>
    <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
        <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
        <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
    </MessageHeader>
    <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
        <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
        <Name>New Name 2</Name>
        <PriorityCode>3</PriorityCode>
        <ProcessingDatePeriod>
          <StartDate>2020-08-14</StartDate>
          <EndDate>2020-08-21</EndDate>
        </ProcessingDatePeriod>
        <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
    </RequestMessage>
  </root>
</root>

use the below XSLT

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/">
      <root>
         <root>
            <MessageHeader>
               <ID>
                  <xsl:value-of select="/root/root/MessageHeader[1]/ID"/>
               </ID>
               <CreationDateTime>
                  <xsl:value-of select="/root/root/MessageHeader[1]/CreationDateTime"/>
               </CreationDateTime>
               <SenderParty>
                  <InternalID>
                     <xsl:if test="/root/root/MessageHeader[1]/SenderParty/InternalID/@schemeID">
                        <xsl:attribute name="schemeID">
                           <xsl:value-of select="/root/root/MessageHeader[1]/SenderParty/InternalID/@schemeID"/>
                        </xsl:attribute>
                     </xsl:if>
                     <xsl:if test="/root/root/MessageHeader[1]/SenderParty/InternalID/@schemeAgencyID">
                        <xsl:attribute name="schemeAgencyID">
                           <xsl:value-of select="/root/root/MessageHeader[1]/SenderParty/InternalID/@schemeAgencyID"/>
                        </xsl:attribute>
                     </xsl:if>
                     <xsl:value-of select="/root/root/MessageHeader[1]/SenderParty/InternalID"/>
                  </InternalID>
               </SenderParty>
               <RecipientParty>
                  <InternalID>
                     <xsl:if test="/root/root/MessageHeader[1]/RecipientParty/InternalID/@schemeID">
                        <xsl:attribute name="schemeID">
                           <xsl:value-of select="/root/root/MessageHeader[1]/RecipientParty/InternalID/@schemeID"/>
                        </xsl:attribute>
                     </xsl:if>
                     <xsl:if test="/root/root/MessageHeader[1]/RecipientParty/InternalID/@schemeAgencyID">
                        <xsl:attribute name="schemeAgencyID">
                           <xsl:value-of select="/root/root/MessageHeader[1]/RecipientParty/InternalID/@schemeAgencyID"/>
                        </xsl:attribute>
                     </xsl:if>
                     <xsl:value-of select="/root/root/MessageHeader[1]/RecipientParty/InternalID"/>
                  </InternalID>
               </RecipientParty>
            </MessageHeader>
            <xsl:for-each select="/root/root/RequestMessage">
               <RequestMessage>
                  <MessageHeader>
                     <xsl:value-of select="MessageHeader"/>
                  </MessageHeader>
                  <RequestMessageInformation>
                     <ID>
                        <xsl:value-of select="RequestMessageInformation/ID"/>
                     </ID>
                     <Name>
                        <xsl:value-of select="RequestMessageInformation/Name"/>
                     </Name>
                     <PriorityCode>
                        <xsl:value-of select="RequestMessageInformation/PriorityCode"/>
                     </PriorityCode>
                     <ProcessingDatePeriod>
                        <StartDate>
                           <xsl:value-of select="RequestMessageInformation/ProcessingDatePeriod/StartDate"/>
                        </StartDate>
                        <EndDate>
                           <xsl:value-of select="RequestMessageInformation/ProcessingDatePeriod/EndDate"/>
                        </EndDate>
                     </ProcessingDatePeriod>
                     <OriginTypeCode>
                        <xsl:value-of select="RequestMessageInformation/OriginTypeCode"/>
                     </OriginTypeCode>
                  </RequestMessageInformation>
               </RequestMessage>
            </xsl:for-each>
         </root>
      </root>
   </xsl:template>
</xsl:stylesheet>


to get below output:

<root>
   <root>
      <MessageHeader>
         <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
         <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
         <SenderParty>
            <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
         </SenderParty>
         <RecipientParty>
            <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
         </RecipientParty>
      </MessageHeader>
      <RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
            <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
            <Name>New Name</Name>
            <PriorityCode>3</PriorityCode>
            <ProcessingDatePeriod>
               <StartDate>2020-08-14</StartDate>
               <EndDate>2020-08-21</EndDate>
            </ProcessingDatePeriod>
            <OriginTypeCode>003</OriginTypeCode>
         </RequestMessageInformation>
      </RequestMessage>
      <RequestMessage>
         <MessageHeader/>
         <RequestMessageInformation>
            <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
            <Name>New Name 2</Name>
            <PriorityCode>3</PriorityCode>
            <ProcessingDatePeriod>
               <StartDate>2020-08-14</StartDate>
               <EndDate>2020-08-21</EndDate>
            </ProcessingDatePeriod>
            <OriginTypeCode>003</OriginTypeCode>
         </RequestMessageInformation>
      </RequestMessage>
   </root>
</root>
0 Kudos

Hello yatanveersingh

Thanks for your answer !

This XSLT cannot work for my case because there are many nodes/fields that can be changed depending on the incoming Data. So, an XSLT with an operation for each node cannot be maintained and the Payload in this post is just an example.

Regards,

Nadir

yatanveersingh
Active Participant
0 Kudos

Can you give a proper xml and explain what is ur requirement.

0 Kudos

Hello yatanveersingh,

I put the Payload and the transformed Payload in a comment above (answer to Sriprasad).

Thanks !

Regards,

Nadir

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Nadir,

First thing is you need to enclose above XML with root tag since its not a valid XML ( without root tag).

For adding root add content modifier and in body use below.

<MainRoot>
${in.body}
</MainRoot>

After that add below XSLT which would give you required output

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="@* | node()">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="MainRoot">
		<xsl:copy>
			<xsl:for-each select="root">			
				<xsl:apply-templates select="MessageHeader"/>
				<xsl:copy-of select="RequestMessage"/>				
			</xsl:for-each>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="MessageHeader[ID = following::MessageHeader/ID]">
		<xsl:copy-of select="MessageHeader"/>
	</xsl:template>  
</xsl:stylesheet>

Regards,

Sriprasad Shivaram Bhat

0 Kudos

Really thanks for your help sriprasadshivaramabhat !

It did not work, maybe an error with my Payload that contains namespaces.

Please find attached the originalpayload.txt and the wantedpayload.txt.

Regards,

Nadir

0 Kudos

Hello sriprasadshivaramabhat,

So I used your XSLT for the Code below:

<MainRoot>
<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089126</ID>
	<Name>New Name</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>
<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089127</ID>
	<Name>New Name 2</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>
</MainRoot>
<br>

And this is the result I got:

<MainRoot>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089126</ID>
         <Name>New Name</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
   <MessageHeader>
      <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
      <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
      <SenderParty>
         <InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
      </SenderParty>
      <RecipientParty>
         <InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
      </RecipientParty>
   </MessageHeader>
   <RequestMessage>
      <MessageHeader/>
      <RequestMessageInformation>
         <ID>FA163EBCE69E1EDAB7C020500C089127</ID>
         <Name>New Name 2</Name>
         <PriorityCode>3</PriorityCode>
         <ProcessingDatePeriod>
            <StartDate>2020-08-14</StartDate>
            <EndDate>2020-08-21</EndDate>
         </ProcessingDatePeriod>
         <OriginTypeCode>003</OriginTypeCode>
      </RequestMessageInformation>
   </RequestMessage>
</MainRoot><br>

There is no Root Node and The MessageHeader node should be before the RequestMessage nodes.

Thanks for your help !

Regards,

Nadir

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Nadir,

Could you please share correct XML with correct start and end tags ( you can put some dummy field name inside each nodes to make it clear )

Regards,

Sriprasad Shivaram Bhat

0 Kudos

Hello sriprasadshivaramabhat,

Thanks for your answer. Is it enough like below?

Original Payload:

<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089126</ID>
	<Name>New Name</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>
<root>
<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
<MessageHeader/>
<RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089127</ID>
	<Name>New Name 2</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
</RequestMessageInformation>
</RequestMessage>
</root>

Transformed Payload:

<root>
<MessageHeader>
        <ID>FA163EBCE69E1EDAB7C01B84C65C7123</ID>
        <CreationDateTime>2020-08-14T07:36:27.072333Z</CreationDateTime>
	<SenderParty>
		<InternalID schemeID="LocalSystemID" schemeAgencyID="310">SENDER1</InternalID>
	</SenderParty>
	<RecipientParty>
		<InternalID schemeID="BusinessSystemID" schemeAgencyID="310">RECEIVER1</InternalID>
	</RecipientParty>
</MessageHeader>
<RequestMessage>
   <MessageHeader/>
   <RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089126</ID>
	<Name>New Name</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
   </RequestMessageInformation>
</RequestMessage>
<RequestMessage>
   <MessageHeader/>
   <RequestMessageInformation>
	<ID>FA163EBCE69E1EDAB7C020500C089127</ID>
	<Name>New Name 2</Name>
	<PriorityCode>3</PriorityCode>
	<ProcessingDatePeriod>
		<StartDate>2020-08-14</StartDate>
		<EndDate>2020-08-21</EndDate>
	</ProcessingDatePeriod>
	<OriginTypeCode>003</OriginTypeCode>
   </RequestMessageInformation>
</RequestMessage>
</root>

Regards,

Nadir