
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.
The response message looks as follows. It contains multiple entry elements which should be processed individually.
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.
We show three approaches to get around this problem.
We remove the namespace information from the XML file by introducing an XSLT mapping step.
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.
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"
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.
After that you can use the name of the namespace mapping in the General Splitter.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |