[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)
- From: Peter Flynn <peter@silmaril.ie>
- To: xml-dev@lists.xml.org
- Date: Thu, 24 Mar 2022 08:28:03 +0000
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 <title></title>
</foo>
]]></programlisting>
and NOT
<programlisting language="XML">
<?xml version="1.0">
<!DOCTYPE foo SYSTEM "bar.dtd">
<foo>
<title>Some &lt;title></title>
</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]