Summary
The following article describes how to manage the encoding and decoding of CDATA sections.
More Information
XML documents may contain CDATA sections which contain text content that is not parsed as XML. The attribute "cdataWrapper" can be added to an element definition in a Service or Client Definition File (CDF or SDF) to influence how the CDATA sections are processed. For example, setting the attribute cdataWrapper="1" on this element:
<element name="theData" type="string" size="128" cdataWrapper="1" />
indicates that the content of element theData may contain a CDATA section when deserialized and must contain a CDATA section when serialized. When the cdataWrapper attribute is not present, the default value is "0".
The following scenarios may occur when working with a CDATA section:
When deserializing (XML -> IPM)
1. If cdataWrapper="1" and the CDATA wrapper is present around data content, then the CDATA content will be deserialized.
XML input:
<input><![CDATA[data]]></input>
IPM output:
data
2. If cdataWrapper="1" and there is no CDATA wrapper around data content, then the data content of that node, if any, will be deserialized.
XML input:
<input>data</input>
IPM output:
data
3. If cdataWrapper="0", or the attribute is omitted, and the CDATA wrapper is present, then the contents of the CDATA section will not be deserialized. The data content of the element, if any, will be deserialized.
XML input:
<input><![CDATA[data]]>other info</input>
IPM output:
other info
When serializing (IPM -> XML)
4. If cdataWrapper="1" then the data content will always be wrapped in CDATA.
IPM input:
data
XML output:
<return><![CDATA[data]]></return>