Skip to Content
Author's profile photo Anirban Mallick

How to use CDATA in PI

Business Requirement:

The business requirement was to encapsulate a grid structure in a string using CDATA tag, i.e., <![CDATA<Business Data>]>.

Problem Statement:

Adding CDATA tag was easy using XSLT mapping and it was tested successfully using SoapUI tool. But once tested with the vendor application, the CDATA tag was missing from the received payload even though the outbound payload in PI message log was having the desired structure with proper CDATA tag.


Root Cause:

Vendor was looking for a string created with the payload and encapsulated within CDATA tag. Using XSLT only added the tag, but it was not able to send the output in a string format.



The objective was achieved using 2 message mappings and one generic XSLT mapping.

The 1st Message Mapping was used to convert the incoming payload from ECC into vendor structure.


The 2nd Message Mapping was used to add CDATA tags & move the entire converted payload into a string. (here in the WhereUsed field)


Then applied a generic XSLT mapping so that PI bypass the CDATA tag while sending data to the vendor.

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

		<xsl:template match="ns1:results">
				<xsl:text disable-output-escaping="yes">&lt;![CDATA[ </xsl:text>
				<xsl:value-of select="." disable-output-escaping="yes"/>
				<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>


Final Operation Mapping for the response would look like below:


Here is a sample response payload from ECC:

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Abir Chakraborty
      Abir Chakraborty

      Thanks!!!! This is very good mate

      Author's profile photo kavi tha
      kavi tha

      Hello Anirban,

      Could you please give me full XSLT code.

      I am facing an issue like “details: Namespace prefix ‘ns1’ is undeclared.”