Re: What characters can go into a CDATA section and a comment? (I found inconsistencies)
Peter Flynn <[email protected]>
| Newsgroups | gmane.text.xml.devel |
|---|---|
| Organization | Silmaril Consultants |
| Message-ID | <[email protected]> |
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 _______________________________________________________________________ XML-DEV is a publicly archived, unmoderated list hosted by OASIS to support XML implementation and development. To minimize spam in the archives, you must subscribe before posting. [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/ Or unsubscribe: [email protected] subscribe: [email protected] List archive: http://lists.xml.org/archives/xml-dev/ List Guidelines: http://www.oasis-open.org/maillists/guidelines.php