<s>
The	O
term	O
CDATA	B-Language
,	O
meaning	O
character	B-Language
data	I-Language
,	O
is	O
used	O
for	O
distinct	O
,	O
but	O
related	O
,	O
purposes	O
in	O
the	O
markup	O
languages	O
SGML	B-Language
and	O
XML	B-Protocol
.	O
</s>
<s>
The	O
term	O
indicates	O
that	O
a	O
certain	O
portion	O
of	O
the	O
document	O
is	O
general	O
character	B-Language
data	I-Language
,	O
rather	O
than	O
non-character	O
data	O
or	O
character	B-Language
data	I-Language
with	O
a	O
more	O
specific	O
,	O
limited	O
structure	O
.	O
</s>
<s>
In	O
an	O
XML	B-Protocol
document	I-Protocol
or	O
external	O
entity	O
,	O
a	O
CDATA	B-Language
section	I-Language
is	O
a	O
piece	O
of	O
element	O
content	O
that	O
is	O
marked	O
up	O
to	O
be	O
interpreted	O
literally	O
,	O
as	O
textual	O
data	O
,	O
not	O
as	O
marked	O
up	O
content	O
.	O
</s>
<s>
A	O
CDATA	B-Language
section	I-Language
is	O
merely	O
an	O
alternative	O
syntax	O
for	O
expressing	O
character	B-Language
data	I-Language
;	O
there	O
is	O
no	O
semantic	O
difference	O
between	O
character	B-Language
data	I-Language
in	O
a	O
CDATA	B-Language
section	I-Language
and	O
character	B-Language
data	I-Language
in	O
standard	O
syntax	O
where	O
,	O
for	O
example	O
,	O
"	O
<	O
"	O
and	O
"	O
&	O
"	O
are	O
represented	O
by	O
"	O
<	O
"	O
and	O
"	O
&	O
"	O
,	O
respectively	O
.	O
</s>
<s>
A	O
CDATA	B-Language
section	I-Language
starts	O
with	O
the	O
following	O
sequence	O
:	O
</s>
<s>
Similarly	O
,	O
if	O
the	O
numeric	B-General_Concept
character	I-General_Concept
reference	I-General_Concept
ð	O
appears	O
in	O
element	O
content	O
,	O
it	O
will	O
be	O
interpreted	O
as	O
the	O
single	O
Unicode	O
character	O
00F0	O
(	O
small	O
letter	O
eth	O
)	O
.	O
</s>
<s>
But	O
if	O
the	O
same	O
appears	O
in	O
a	O
CDATA	B-Language
section	I-Language
,	O
it	O
will	O
be	O
parsed	O
as	O
six	O
characters	O
:	O
ampersand	O
,	O
hash	O
mark	O
,	O
digit	O
2	O
,	O
digit	O
4	O
,	O
digit	O
0	O
,	O
semicolon	O
.	O
</s>
<s>
New	O
authors	O
of	O
XML	B-Protocol
documents	I-Protocol
often	O
misunderstand	O
the	O
purpose	O
of	O
a	O
CDATA	B-Language
section	I-Language
,	O
mistakenly	O
believing	O
that	O
its	O
purpose	O
is	O
to	O
"	O
protect	O
"	O
data	O
from	O
being	O
treated	O
as	O
ordinary	O
character	B-Language
data	I-Language
during	O
processing	O
.	O
</s>
<s>
Some	O
APIs	O
for	O
working	O
with	O
XML	B-Protocol
documents	I-Protocol
do	O
offer	O
options	O
for	O
independent	O
access	O
to	O
CDATA	B-Language
sections	I-Language
,	O
but	O
such	O
options	O
exist	O
above	O
and	O
beyond	O
the	O
normal	O
requirements	O
of	O
XML	B-Protocol
processing	O
systems	O
,	O
and	O
still	O
do	O
not	O
change	O
the	O
implicit	O
meaning	O
of	O
the	O
data	O
.	O
</s>
<s>
Character	B-Language
data	I-Language
is	O
character	B-Language
data	I-Language
,	O
regardless	O
of	O
whether	O
it	O
is	O
expressed	O
via	O
a	O
CDATA	B-Language
section	I-Language
or	O
ordinary	O
markup	O
.	O
</s>
<s>
CDATA	B-Language
sections	I-Language
are	O
useful	O
for	O
writing	O
XML	B-Protocol
code	O
as	O
text	O
data	O
within	O
an	O
XML	B-Protocol
document	I-Protocol
.	O
</s>
<s>
For	O
example	O
,	O
if	O
one	O
wishes	O
to	O
typeset	O
a	O
book	O
with	O
XSL	B-Language
explaining	O
the	O
use	O
of	O
an	O
XML	B-Protocol
application	O
,	O
the	O
XML	B-Protocol
markup	O
to	O
appear	O
in	O
the	O
book	O
itself	O
will	O
be	O
written	O
in	O
the	O
source	O
file	O
in	O
a	O
CDATA	B-Language
section	I-Language
.	O
</s>
<s>
A	O
CDATA	B-Language
section	I-Language
cannot	O
contain	O
the	O
string	O
"	O
 ] ]	O
>	O
"	O
and	O
therefore	O
it	O
is	O
not	O
possible	O
for	O
a	O
CDATA	B-Language
section	I-Language
to	O
contain	O
nested	O
CDATA	B-Language
sections	I-Language
.	O
</s>
<s>
The	O
preferred	O
approach	O
to	O
using	O
CDATA	B-Language
sections	I-Language
for	O
encoding	O
text	O
that	O
contains	O
the	O
triad	O
"	O
 ] ]	O
>	O
"	O
is	O
to	O
use	O
multiple	O
CDATA	B-Language
sections	I-Language
by	O
splitting	O
each	O
occurrence	O
of	O
the	O
triad	O
just	O
before	O
the	O
"	O
>	O
"	O
.	O
</s>
<s>
This	O
means	O
that	O
to	O
encode	O
"	O
 ] ]	O
>	O
"	O
in	O
the	O
middle	O
of	O
a	O
CDATA	B-Language
section	I-Language
,	O
replace	O
all	O
occurrences	O
of	O
"	O
 ] ]	O
>	O
"	O
with	O
the	O
following	O
:	O
</s>
<s>
This	O
effectively	O
stops	O
and	O
restarts	O
the	O
CDATA	B-Language
section	I-Language
.	O
</s>
<s>
In	O
text	O
data	O
,	O
any	O
Unicode	O
character	O
not	O
available	O
in	O
the	O
encoding	O
declared	O
in	O
the	O
<?xml ...?>	O
header	O
can	O
be	O
represented	O
using	O
a	O
&	O
#nnn	O
;	O
numerical	B-General_Concept
character	I-General_Concept
reference	I-General_Concept
.	O
</s>
<s>
But	O
the	O
text	O
within	O
a	O
CDATA	B-Language
section	I-Language
is	O
strictly	O
limited	O
to	O
the	O
characters	O
available	O
in	O
the	O
encoding	O
.	O
</s>
<s>
Because	O
of	O
this	O
,	O
using	O
a	O
CDATA	B-Language
section	I-Language
programmatically	O
to	O
quote	O
data	O
that	O
could	O
potentially	O
contain	O
'	O
&	O
 '	O
or	O
'	O
<	O
'	O
characters	O
can	O
cause	O
problems	O
when	O
the	O
data	O
happens	O
to	O
contain	O
characters	O
that	O
cannot	O
be	O
represented	O
in	O
the	O
encoding	O
.	O
</s>
<s>
Another	O
issue	O
is	O
that	O
an	O
XML	B-Protocol
document	I-Protocol
can	O
be	O
transcoded	O
from	O
one	O
encoding	O
to	O
another	O
during	O
transport	O
.	O
</s>
<s>
When	O
the	O
XML	B-Protocol
document	I-Protocol
is	O
converted	O
to	O
a	O
more	O
limited	O
character	O
set	O
,	O
such	O
as	O
ASCII	O
,	O
characters	O
that	O
can	O
no	O
longer	O
be	O
represented	O
are	O
converted	O
to	O
&	O
#nnn	O
;	O
character	O
references	O
for	O
a	O
lossless	O
conversion	O
.	O
</s>
<s>
But	O
within	O
a	O
CDATA	B-Language
section	I-Language
,	O
these	O
characters	O
can	O
not	O
be	O
represented	O
at	O
all	O
,	O
and	O
have	O
to	O
be	O
removed	O
or	O
converted	O
to	O
some	O
equivalent	O
,	O
altering	O
the	O
content	O
of	O
the	O
CDATA	B-Language
section	I-Language
.	O
</s>
<s>
CDATA	B-Language
sections	I-Language
in	O
XHTML	B-Language
documents	O
are	O
liable	O
to	O
be	O
parsed	O
differently	O
by	O
web	O
browsers	O
if	O
they	O
render	O
the	O
document	O
as	O
HTML	O
,	O
since	O
HTML	O
parsers	O
do	O
not	O
recognise	O
the	O
CDATA	B-Language
start	O
and	O
end	O
markers	O
,	O
nor	O
do	O
they	O
recognise	O
HTML	O
entity	O
references	O
such	O
as	O
<	O
within	O
<script>	O
tags	O
.	O
</s>
<s>
This	O
can	O
cause	O
rendering	O
problems	O
in	O
web	O
browsers	O
and	O
can	O
lead	O
to	O
cross-site	O
scripting	O
vulnerabilities	O
if	O
used	O
to	O
display	O
data	O
from	O
untrusted	O
sources	O
,	O
since	O
the	O
two	O
kinds	O
of	O
parser	O
will	O
disagree	O
on	O
where	O
the	O
CDATA	B-Language
section	I-Language
ends	O
.	O
</s>
<s>
Since	O
it	O
is	O
useful	O
to	O
be	O
able	O
to	O
use	O
less-than	O
signs	O
(	O
< )  and ampersands (& )  in web page scripts, and to a lesser extent styles, without having to remember to escape them, it is common to use CDATA markers around the text of inline <script> and <style>	O
elements	O
in	O
XHTML	B-Language
documents	O
.	O
</s>
<s>
But	O
so	O
that	O
the	O
document	O
can	O
also	O
be	O
parsed	O
by	O
HTML	O
parsers	O
,	O
which	O
do	O
not	O
recognise	O
the	O
CDATA	B-Language
markers	O
,	O
the	O
CDATA	B-Language
markers	O
are	O
usually	O
commented-out	O
,	O
as	O
in	O
this	O
JavaScript	B-Language
example	O
:	O
</s>
<s>
or	O
this	O
CSS	B-Language
example	O
:	O
</s>
<s>
CSS	B-Language
stylesheets	I-Language
,	O
for	O
example	O
,	O
only	O
support	O
the	O
second	O
style	O
of	O
commenting-out	O
(	O
)	O
,	O
but	O
CSS	B-Language
also	O
has	O
less	O
need	O
for	O
the	O
<	O
and	O
&	O
characters	O
than	O
JavaScript	B-Language
and	O
so	O
less	O
need	O
for	O
explicit	O
CDATA	B-Language
markers	O
.	O
</s>
<s>
In	O
Document	B-Language
Type	I-Language
Definition	I-Language
(	O
DTD	O
)	O
files	O
for	O
SGML	B-Language
and	O
XML	B-Protocol
,	O
an	O
attribute	O
value	O
may	O
be	O
designated	O
as	O
being	O
of	O
type	O
CDATA	B-Language
:	O
arbitrary	O
character	B-Language
data	I-Language
.	O
</s>
<s>
Within	O
a	O
CDATA-type	O
attribute	O
,	O
character	O
and	O
entity	O
reference	O
markup	O
is	O
allowed	O
and	O
will	O
be	O
processed	O
when	O
the	O
document	O
is	O
read	O
.	O
</s>
<s>
it	O
means	O
that	O
elements	O
named	O
foo	O
may	O
optionally	O
have	O
an	O
attribute	O
named	O
"	O
a	O
"	O
which	O
is	O
of	O
type	O
CDATA	B-Language
.	O
</s>
<s>
In	O
an	O
XML	B-Protocol
document	I-Protocol
that	O
is	O
valid	O
according	O
to	O
this	O
DTD	O
,	O
an	O
element	O
like	O
this	O
might	O
appear	O
:	O
</s>
<s>
and	O
an	O
XML	B-Protocol
parser	I-Protocol
would	O
interpret	O
the	O
"	O
a	O
"	O
attribute	O
's	O
value	O
as	O
being	O
the	O
character	B-Language
data	I-Language
"	O
1	O
&	O
2	O
are	O
<	O
3	O
"	O
.	O
</s>
<s>
An	O
SGML	B-Language
or	O
XML	B-Language
DTD	I-Language
may	O
also	O
include	O
entity	O
declarations	O
in	O
which	O
the	O
token	O
CDATA	B-Language
is	O
used	O
to	O
indicate	O
that	O
entity	O
consists	O
of	O
character	B-Language
data	I-Language
.	O
</s>
<s>
The	O
character	B-Language
data	I-Language
may	O
appear	O
within	O
the	O
declaration	O
itself	O
or	O
may	O
be	O
available	O
externally	O
,	O
referenced	O
by	O
a	O
URI	B-Protocol
.	O
</s>
