Is CDATA "structure"?

Tom Otvos tom.otvos at
Thu Jul 15 14:57:16 BST 1999

Hello all,
I was hoping that the general wisdom on this list might be able to help
settle a development debate we are having here.  In an app we are working
on, we are creating XML documents that have, as content to some elements,
HTML.  When writing out these documents, the elements which contain HTML
wrap their content in CDATA sections to avoid having to entity-encode all of
the angle brackets and ampersands.
Now, as product development progressed, we found that we wanted to preserve
the formatting of the HTML content, which required entity-encoding carriage
returns in the HTML so that the parser would return them correctly.
Naturally, the entity encodings had to appear outside of a CDATA section, so
the HTML elements were now broken up into many smaller CDATA sections,
separated by entity-encoded carriage returns.  
It was starting to look goofy, but it worked ok.  Then (just for fun) we
opened up our documents in a variety of XML editors (like IE5, which I know
is not an editor but it does display the structure).  To our surprise, the
CDATA sections were showing up in the structure, whereas the entity
encodings were silently converted.  A debate ensued as to whether or not
this was right, and whether or not our use of CDATA was "dumb".  The
proposed alternative was to skip CDATA altogether and just entity-encode the
HTML, making it virtually illegible in a text editor but very readable in an
XML editor.
So, my question is should CDATA sections in an XML document be considered
structural, and warrant being displayed in an XML editor, or should they be
considered more like "parser control" and be silently interpreted in the
same way that entity encodings are?  Although we cannot change the way the
current crop of XML editors behaves, it would be nice to know what the
conventional wisdom *thinks* should be happening.
Tom Otvos
Director of Research, Pervasive Software Inc.
"Try not! Do, or do not. There is no 'try'." - Yoda

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list