For the past 14 years I have not done a lot with CDATA Elements. If you do not know much about them, they are tags you put around a blob of data to tell the XML parsing systems to skip over them. It will allow you to have < and & inside the data block without having to escape them. They can be useful if you need to place another XML messages inside another one without having to worry about escaping the inner XML tags.
The CDATA tags look like <![CDATA[ ANY DATA HERE ]]>
<?xml version="1.0" encoding="utf-8"?>
<OriginalOrder><![CDATA[<?xml version="1.0" encoding="utf-8"?><Order>…</Order>]]></OriginalOrder>
How does BizTalk handle CDATA? Well, BizTalk does what it should when it receives a node with a CDATA section. The XML Disassembler skips the parsing of the inner data. The maps are where you can run into issues because they will remove the CDATA tags when the data is being mapped.
Luckily they provided a way for you to add the CDATA sections back into the output message to ensure they are escaped correctly. You can do that by setting the property called CDATA section elements.
This is accessible by clicking any open area on the map canvas. While this looks straight forward, it is a little tricky. This property needs to be a namespace prefixed space separated list of values that you want to be enclosed in CDATA. Lets look at the example below and assume a default namespace of ns0.
If you wanted all three nodes on the output to have CDATA tags you would set the CDATA section elements property to:
”ns0:AddressXML ns0:OrderXML ns0:HistoryXML”
Something else to point out is the mapper does runtime validation on the elements in the CDATA section elements property. If you entered ns4:Item and ns4 was not a defined namespace prefix you will get an exception when the map runs.
Hope you learned a little about how BizTalk Maps handles CDATA. Enjoy.