How can the CDATA ending delimiter "]]>" be represented within a CDATA
section itself?
Consider an XML document that is intended to contain an embedded,
uninterpreted XML example. Generally, the easiest way to represent it would
be to put the embedded XML example inside a CDATA section. But if the
example has a CDATA section itself, then the ending delimiter will be
interpreted as the end of the "real" CDATA section. Here's even a simpler
example with a script's conditional statement:
<test>
<!CDATA[
...
if g[a[i]]>f ...
...
]]>
</test>
This element returns errors when viewed and/or validated in VS.Net and IE 6.
They both interpret the "]]>" within the "if g[a[i]]>f ..." statement as the
end of the CDATA section. Multiple SGML sources on the web indicate that
the above XML should process correctly without change. Others say that the
">" (greater than) should be escaped inside the CDATA section using the
entity reference >. For example:
<test>
<!CDATA[
...
if g[a[i]]>f ...
...
]]>
</test>
But this doesn't work either because entity references are not interpreted
within a CDATA section. That's the whole point of the CDATA section... to
represent literal character data without escapes.
Is it even possible then? Or is this just a bug in all MS XML parsers?