Lists Home |
Date Index |
This is one of those common misconceptions.
First of all, if you want to include ]]> in a single CDATA section, you
simply cannot. In order to accomplish this, you need to break the text up
into two text nodes, where the first text node contains at least ] and at
most ]], and the second contains ]> or >. The reason that you need to
escape the > in ]]> is for compatibility with SGML parsers, which recognize
this as a special sequence [a marked section end] in text and cause parsing
Some parsers and DOM implementations will quietly merge adjacent text nodes
on input. The DOMM also contains a method to normalize adjacent text nodes
into a single node, so having to use two text nodes for the data is usually
not a problem.
Text inside <![CDATA[ ]]> does not undergo replacement. In SGML terms, it is
character data, which, unlike replacable character data, is not subject to
any substitutions whatsoever.
From: Collin [mailto:email@example.com]
Sent: Tuesday, October 15, 2002 10:41 PM
Subject: [xml-dev] Discussion about XML Specification(SE)
The following is an actual text in XML Specification(SE).
The right angle bracket (>) may be represented using the string
">", and must, for compatibility, be escaped using ">" or a
character reference when it appears in the string "]]>" in
content, when that string is not marking the end of a CDATA
According to the above description, we are supposed to escape '>' using
But the problem is that is there another way for us, in the content of CDATA
section, to write the '>' in ']]>' without using a '>'?
I find out there isn't such a method. So actuall we MUST do that,
instead of FOR COMPATIBILITY, which is descripted in the XML