Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
monikasch
Explorer

Hello together,

In Cloud Integration, the General Splitter can be used in Integration Flows to split a payload in multiple segments and process each segment individually. However, if global namespaces are involved, the General Splitter might not work as expected. If not configured correctly, it behaves as if the payload was empty which means that the following steps are not executed.

In our example Integration Flow, we fetch data from a webservice using an HTTP adapter and split the response message before calling a Local Integration Flow.

henningb23_0-1714027042754.png

The response message looks as follows. It contains multiple entry elements which should be processed individually.

henningb23_0-1714028311090.png

When using the XPath expression //entry in the General Splitter, the splitting step does not produce any output, so the following steps in the Integration Flow are never reached.

henningb23_1-1714028522913.png

We show three approaches to get around this problem.

1. Removing Namespaces

We remove the namespace information from the XML file by introducing an XSLT mapping step.

henningb23_2-1714029203533.png

In our example, we use the following XSLT mapping which also simplifies the payload a bit.

<!--
    XSL stylesheet for removing namespace prefixes and declarations.
    The stylesheet also removes XML elements that are not needed
    for the following steps.
-->
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
	xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
	xmlns:a="http://www.w3.org/2005/Atom" exclude-result-prefixes="m d a">

	<xsl:template match="/">
		<feed>
			<xsl:apply-templates select="//a:entry" />
		</feed>
	</xsl:template>

	<xsl:template match="a:entry">
		<entry>
			<xsl:apply-templates select="a:content" />
		</entry>
	</xsl:template>

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

	<!-- templates to remove namespace prefix -->
	<xsl:template match="d:*">
		<xsl:element name="{local-name()}">
			<!-- <xsl:apply-templates select="@*|node()"/> -->
			<xsl:apply-templates select="node()" />
		</xsl:element>
	</xsl:template>
	<xsl:template match="m:*">
		<xsl:element name="{local-name()}">
			<xsl:apply-templates select="@*|node()" />
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>

After adding the XSLT mapping step the General Splitter works as expected when using //entry XPath expression.

2. Adding Namespace Information to the XPath Expression

The probably most straightforward solution is to add namespace information to the XPath expression. Since the XML file's root element feed belongs to the namespace http://www.w3.org/2005/Atom, all the other elements - including entry - also belong to this namespace as long as no other namespace is specified for them. Therefore, we add a namespace prefix atom and the namespace URL to the XPath expression as follows:

//atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

henningb23_3-1714030451314.png

3. Adding Namespace Information Globally

It is also possible to add the namespace declaration globally in the Integration Flow's Runtime Configuration. This is the best solution if a namespace is used at multiple places.

In our example, we enter xmlns:atom=http://www.w3.org/2005/Atom as Namespace Mapping.

henningb23_5-1714031082527.png

After that you can use the name of the namespace mapping in the General Splitter.

henningb23_6-1714031148021.png

Conclusion

We showed three solutions to get around problems when using the General Splitter for dividing payloads with a global namespace. We hope this information can help you if you are struggling with the same problem.

Further information about this topic can be found on the SAP Help Portal: General and Iterating Splitter Examples 

We are open for improvements and questions.

Monika and Henning from Integration Team
RealCore Group

Labels in this area