Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Clearly, this question is purely academic. Fortunately, it has a very definite answer.</p> <p>You cannot escape a CDATA end sequence. Production rule 20 of the XML <a href="http://www.w3.org/TR/REC-xml/#sec-cdata-sect" rel="noreferrer">specification</a> is quite clear:</p> <pre><code>[20] CData ::= (Char* - (Char* ']]&gt;' Char*)) </code></pre> <p>EDIT: This product rule literally means "A CData section may contain anything you want BUT the sequence ']]>'. No exception.".</p> <p>EDIT2: The <a href="http://www.w3.org/TR/REC-xml/#sec-cdata-sect" rel="noreferrer">same section</a> also reads:</p> <blockquote> <p>Within a CDATA section, only the CDEnd string is recognized as markup, so that left angle brackets and ampersands may occur in their literal form; they need not (and cannot) be escaped using "<code>&amp;lt;</code>" and "<code>&amp;amp;</code>". CDATA sections cannot nest.</p> </blockquote> <p>In other words, it's not possible to use entity reference, markup or any other form of interpreted syntax. The only parsed text inside a CDATA section is <code>]]&gt;</code>, and it terminates the section.</p> <p>Hence, it is not possible to escape <code>]]&gt;</code> within a CDATA section.</p> <p>EDIT3: The <a href="http://www.w3.org/TR/REC-xml/#sec-cdata-sect" rel="noreferrer">same section</a> also reads: </p> <blockquote> <p>2.7 CDATA Sections</p> <p>[Definition: CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string "&lt;![CDATA[" and end with the string "]]&gt;":] </p> </blockquote> <p>Then there may be a CDATA section anywhere character data may occur, including multiple adjacent CDATA sections inplace of a single CDATA section. That allows it to be possible to split the <code>]]&gt;</code> token and put the two parts of it in adjacent CDATA sections.</p> <p>ex:</p> <pre><code>&lt;![CDATA[Certain tokens like ]]&gt; can be difficult and &lt;invalid&gt;]]&gt; </code></pre> <p>should be written as</p> <pre><code>&lt;![CDATA[Certain tokens like ]]]]&gt;&lt;![CDATA[&gt; can be difficult and &lt;valid&gt;]]&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload