[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What characters can go into a CDATA section and acomment?

  • From: Peter Flynn <peter@silmaril.ie>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 24 Mar 2022 08:28:03 +0000

Re:  What characters can go into a CDATA section and acomment?
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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.