Toad World® Forums

Improve handling of embedded CDATA segments in XML export


#1

Currently, embedded CDATA segments in eg outcome are replaced as follows in the XML export file:

“” is replaced by “{73216B1F-624F-4707-9F5B-7F9E5FC13A2C}”

I understand the reasoning behind these replacements, but the fact is that it breaks the XML documents used in outcomes if these contain CDATA sections.

In order to restore the original XML documents one must perform the following replacements:

“{7F90763C-0E3B-4EDB-9901-25FFC60D4CE3}” by “<![CDATA[>”

but this is obviously tedious to do manually for every export (unless one can write a script or program that does this).

Instead, Code Tester should be changed, such that the following replacements are made instead of the current ones, which is the de facto standard of handling embedded CDATA segments:

“” should be replaced by “]]]]><![CDATA[>”

The reasoning behind the replacement of “]]>” is that the three characters are split over two CDATA sections, the first one ends with “]]” + the CDATA “end sequence” and then a new CDATA section begins with “>”.

Cheers

Finn


#2

Thanks Finn!

Will forward this Enhancement request to PM.

/Danny


#3

I cannot agree that it is the XML standard. As far as I know w3c in their documentation has the following note: “”
Nested CDATA.png


#4

I cannot agree that it is the XML standard. As far as I know w3c in their documentation has the following note: “Nested CDATA sections are not allowed”.

So replacing nested CDATA “brackets” with GUIDs is a trick. We did not think about letting users to work with XML files manually but real life has its own demands .

But your proposition looks more elegant and more popular. So we will try to use it in one of our close releases.


#5

Hi Leonid

That example is from W3School, not W3C

http://www.w3schools.com/xml/xml_cdata.asp

and they’re wrong, look here:

Cheers

Finn


#6

Hi Finn,

You are right: my example was from w3cSchool. But here is an example from W3c document.

My point was that despite I cannot agree that the replacement of “]]>” with the “]]]]><![CDATA[>” is an XML standard I like this idea and will think how can we switch to it.

Regards,

Leonid.


#7

Hi Leonid

Looking at this again: I think I’ve been misreading the bit “CDATA sections cannot nest”. I think I understand what they mean now: This is just like in some programming languages you can nest multiline comments ("/* */"), in others not.

So what they’re saying is that the XML standard doesn’t allow nested CDATA sections like:

<![CDATA[abc]]>

(nested CDATA section underlined) as the first occurrence of “]]>” will close the first CDATA section because the XML parser is not treating the second “<![CDATA[” as a nested section because they’re not allowed.

So the recommended solution is a workaround to the fact that CDATA sections cannot be nested. In fact, the solution instead chains them, such that the above mentioned example would be:

<![CDATA[abc]]>

Well, that’s my current understanding. Hope this clarifies.

Cheers

Finn