Adding CDATA section to XML element

This post explains the process of adding CDATA section to an XML element using the RenderXML activity in BW6. The Tibco BW documentation (RenderXML section) contains very basic explanation for achieving this goal, however, I would like to explain the steps required regarding these two cases:

  • having schema with elements defined not as global;
  • having schema with no default namespace;

In short, the solution lays in altering the .bwp process in some text editor and wrapping the elements in CDATA. But let us go through the long path:

 

Case 1: Adding CDATA section to XML elements not defined as global

 

Specific for this case is that when the elements in the schema are not defined as global (under root element), they are not displayed to be selected when clicking the plus button under the Advanced tab of the RenderXML activity. Here is an explanation of the steps needed to achieve that.

Snippet of the input message:

Step1: Click the + button under the Advanced tab of the RenderXML activity. Only the root element – CATALOG is displayed. Select the root element.

 

Selecting root element

 

CATALOG element will be displayed under Advanced tab.

 

Searching for the Catalog element

 

Step2: Open the. bwp process in notepad editor. Search “cdata” and find the CATALOG element.

 

Open the. bwp process in notepad editor

 

Step3: Replace CATALOG with the element that is required to have CDATA section, in the example I will use TITLE and COMPANY. Save the changes and refresh the module in BW6 studio in order the changes to take effect.

 

Replace CATALOG with the element that is required to have CDATA section, here is used TITLE and COMPANY

 

Opening Advanced Tab under RenderXML activity should contain the changes made.

 

Opening Advanced Tab under RenderXML activity should contain the changes made.

 

Validation, the output xml contains TITLE and COMPANY elements with values wrapped in CDATA section.

 

Validation, the output xml contains TITLE and COMPANY elements with values wrapped in CDATA section.

 

Case 2: Adding CDATA to XML elements not defined as global in schema without default namespace

 

This is similar like the previous scenario, specific is that one additional change needs to be made for the final result to be met.

Step1: Click the + button under the Advanced tab of the RenderXML activity. Only the root element – CATALOG is displayed. Select the root element – CATALOG.

CATALOG element will be displayed under Advanced tab. You can notice that unlike the first scenario the namespace is defined as {null}.

CATALOG element will be displayed under Advanced tab. Notice, unlike the first scenario the namespace is defined as {null}.

 

Repeat Steps 2,3 from previous scenario.

 

Replace CATALOG element with elements that are required to have CDATA section. In this example TITLE and ARTIST.

 

Replace CATALOG element with elements that are required to have CDATA section. In this example TITLE and ARTIST.

 

Replace CATALOG element with elements that are required to have CDATA section. In this example TITLE and ARTIST.

 

Refresh module in designer.

 

CATALOG element will be displayed under Advanced tab.

 

Configured like this, the code will not produce the desired output. This is caused by the {null} part.

Even though {null} points that no namespace is defined, the XSLT processor actually is looking for element TITLE with namespace null.

 

Step4: To fix this, you should manually remove the null part.

 

Manually removing the null part

 

Refresh module in designer.

 

Refresh module in designer.

 

Validation: the output xml contains TITLE and ARTIST elements with values wrapped in CDATA section.

 

the output xml contains TITLE and ARTIST elements with values wrapped in CDATA section.