DB2 Version 9.7 for Linux, UNIX, and Windows

Treatment of CDATA sections in annotated XML schema decomposition

The contents of CDATA sections are inserted into the database for elements that are annotated for decomposition. The CDATA section delimiters ("<![CDATA[" and "]]>") can also be inserted. The CDATA contents are subject to line-ending normalization by the XML parser.

Without the attribute db2-xdb:contentHandling, the contents of CDATA sections are inserted into the database for elements that are annotated for decomposition. The CDATA section delimiters are not inserted.

If the XML element declaration in the XML schema is annotated with the attribute db2-xdb:contentHandling="serializeSubtree", the CDATA section, including the CDATA delimiters, are inserted when decomposing a non-parsed XML document.

Difference in decomposition results between non-parsed XML and parsed XML

There are differences when decomposing a CDATA section when the corresponding element declaration is annotated with the attribute db2-xdb:contentHandling="serializeSubtree". The result depends on whether the input XML document is non-parsed XML or parsed XML. For example, an XML document is stored as non-parsed XML in a CLOB column and as parsed XML in an XML column.

The decomposition result preserves the boundaries and the original contents of any CDATA sections in the element if the input XML document comes from a non-XML type column. If the input document come from a XML type column, the CDATA sections are not preserved in the decomposition results. For example, consider an XML document containing the following fragment:

<a> before cdata <![CDATA[ in cdata & <>]]> after cdata</a>

Decomposition produces the following result for the column mapped to element a, when db2-xdb:contentHandling="serializeSubtree" is specified in the mapping for element a if the document is stored in a CLOB column:

<a>before cdata <![CDATA[ in cdata & <>]]> after cdata</a>

If the XML document is stored in an XML type column, the decomposition result for that XML fragment is:

<a> before cdata in cdata &amp; < &gt; after cdata</a>

The non-preservation of the original CDATA section occurs whenever decomposition gets its input document from a XML type column. Although the non-preservation of the original CDATA section is not a correctness issue because the alternate is logically equivalent to the original, it might be different than the expected output.