Nested XML - CData inconsistencies

Details

Description

Trying to insert XML data into an existing XML document. Success of this operation appears to be dependant on the size of data held in the nested XML child elements. Operation works fine up to a certain size with nested XML correctly wrapped within CDATA. However, if child elements are over a certain size then nested XML is not recognised as CDATA and the <> chars are escaped, causing parsing problems further down the line.

For an example I have used the EasyPO xsd as provided on the XMLBeans website, and adding the folowing data as my nested XML:

SUCCESSFUL RUN

<nestedXML>
<testData>
<textDataOne>hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world </textDataOne>
<sizeTextDataOne>324 bytes</sizeTextDataOne>
<textDataTwo>hello</textDataTwo>
<sizeTextDataTwo>5 bytes</sizeTextDataTwo>
</testData>
</nestedXML>

<nestedXML>
<testData>
<textDataOne>hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world </textDataOne>
<sizeTextDataOne>324 bytes</sizeTextDataOne>
<textDataTwo>hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world </textDataTwo>
<sizeTextDataTwo>324 bytes</sizeTextDataTwo>
</testData>
</nestedXML>

Output as follows:

<?xml version="1.0" encoding="UTF-8"?>
<purchase-order xmlns="http://openuri.org/easypo">
<customer>
<name>Gladys Kravitz</name>
<address>Anytown, PA</address>
</customer>
<date>2003-01-07T14:16:00-05:00</date>
<line-item>
<description>Burnham's Celestial Handbook, Vol 1</description>
<per-unit-ounces>5</per-unit-ounces>
<price>21.79</price>
<quantity>2</quantity>
</line-item>
<line-item>
<description>Burnham's Celestial Handbook, Vol 2</description>
<per-unit-ounces>5</per-unit-ounces>
<price>19.89</price>
<quantity>2</quantity>
</line-item>
<line-item><description><nestedXML>
<testData>
<textDataOne>hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world </textDataOne>
<sizeTextDataOne>324 bytes</sizeTextDataOne>
<textDataTwo>hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world </textDataTwo>
<sizeTextDataTwo>324 bytes</sizeTextDataTwo>
</testData>
</nestedXML></description></line-item><shipper>
<name>ZipShip</name>
<per-ounce-rate>0.74</per-ounce-rate>
</shipper>
</purchase-order>