cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing XML Payloads in SAP CPI

0 Kudos

How to compare the two incoming xml payload's from databases and finding the difference between the payloads in sap cpi?

View Entire Topic
Bais
Participant
0 Kudos

This is an XSLT Mapping example we used in past to resolve quickly this problem

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="@*|node()">
	<xsl:copy>
		<xsl:apply-templates select="@*|node()"/>
	</xsl:copy>
</xsl:template>

<!--
<root>
	<new>
		<crm>
			<item>
	<old>
		<crm>
			<item>

-->


<xsl:template match="/">
	<crm>
		<xsl:apply-templates select="/root/new/crm/item"/>
	</crm>
</xsl:template>

<xsl:template match="item">
	<xsl:variable name="id" select="SUCCESSFACTORS_ID"/>

	<xsl:if test="not( /root/old/crm/item[ SUCCESSFACTORS_ID = $id ] )">
		<!-- NEW ELEMENT -->
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:if>

	<xsl:if test="/root/old/crm/item[ SUCCESSFACTORS_ID = $id ]">
		<xsl:if  test="not( . = /root/old/crm/item[ SUCCESSFACTORS_ID = $id ])" >
			<!-- MODIFIED ELEMENT -->
			<xsl:copy>
				<xsl:apply-templates select="@*|node()"/>
			</xsl:copy>
		</xsl:if>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>
we just created a merged xml on Content Modifier before launch it.if you need more explain contact me.