line end handling in CDATA section

S

Spacen Jasset

I've read the XML standard, and I wonder if someone can confirm this
for me.

Am I right in thinking that line endings are translated even within
CDATA sections? The standard states that translation occurs before
parsing so this appears to be the case.
 
J

Joe Kesselman

Spacen said:
Am I right in thinking that line endings are translated even within
CDATA sections? The standard states that translation occurs before
parsing so this appears to be the case.

That's how I'm reading it. CDATA sections are something of a minor
abomination anyway; it's generally better to use character-by-character
escaping where needed. (Or, if you're trying to pass a block of binary
data, to encode it as base-64 or something of that sort.)

CDATA Sections were provided to let people more easily cut-and-paste
some -- not all! -- non-XML data into XML documents. But these days,
given decent XML editing tools which automate the escaping task, there's
really very little need for the <![[CDATA[]]> kluge. The one exception
is working with tools that don't support XML properly, and I would
advise beating up the authors of those tools to get them fixed.
 
R

Richard Tobin

Spacen Jasset said:
Am I right in thinking that line endings are translated even within
CDATA sections? The standard states that translation occurs before
parsing so this appears to be the case.

Yes. The idea is that you get the same results whatever line-ending
convention your system uses. If you want to force a particular
character, you have to use a character reference.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top