XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] What characters can go into a CDATA section and acomment? (I found inconsistencies)

On 24/03/2022 05:06, Mukul Gandhi wrote:
Hi all,
    I personally see, few similarities between purposes of CDATA section and a comment within the context of XML documents.

I seem to clearly, understand the purpose of comments. Any text within comments, are only for human reading (and rarely for automated reading by computers. for e.g, we have XPath comment nodes).

But I'd like to know, what are the use cases of CDATA sections. Any thoughts, shall be helpful to know.
THE most important use case IMNSHO is for documenting markup. I like to be able to write:

<programlisting language="XML"><![CDATA[
<?xml version="1.0">
<!DOCTYPE foo SYSTEM "bar.dtd">
<foo>
<title>Some &lt;title></title>
</foo>
]]></programlisting>

and NOT

<programlisting language="XML">
&lt;?xml version="1.0">
&lt;!DOCTYPE foo SYSTEM "bar.dtd">
&lt;foo>
&lt;title>Some &amp;lt;title>&lt;/title>
&lt;/foo>
</programlisting>

SGML had other types of Marked Section, but they did not make it into XML because the stricter syntax made them unnecessary, and TBH they didn't really get a lot of use, whereas CDATA sections are a mainstay.

CDATA sections are also used by many web developers unsure of exactly /what/ a user is going to input, and exactly /when/ in subsequent non-XML processes the markup is going to be stripped, so they use it as a safety-net of last resort, which often goes wrong; but that seems to be an acceptable price for them for passing the buck to someone else's code.

Peter


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS