Re: What characters can go into a CDATA section and a comment? (I found inconsistencies)
David Carlisle <[email protected]>
| Newsgroups | gmane.text.xml.devel |
|---|---|
| Message-ID | <CAEW6iOjaDrp-x4K_GCi8gpp1QpBvJ4UypzZeJQCOFN8gVdbK2Q@mail.gmail.com> |
On Thu, 24 Mar 2022 at 09:18, Mukul Gandhi <[email protected]> wrote: > On Thu, Mar 24, 2022 at 1:58 PM Peter Flynn <[email protected]> wrote: > >> 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> >> > > How is above mentioned code snippet, more useful than writing within > comments like below, > > <programlisting language="XML"> > <!--<?xml version="1.0"> > <!DOCTYPE foo SYSTEM "bar.dtd"> > <foo> > <title>Some <title></title> > </foo>--> > </programlisting> > one has a source code listing in the document and one does not, as it has been commented out, these are completely different things. a CDATA section plays the same role as a verbatim environment in latex or raw strings in python or ... Yes it's syntactic sugar but for a human reader of the source it is a lot easier to read a (say) javascript listing as javascript rather than javascript in which every < is written as < > > It seems to me that, XML comments are meant to be ignored (they're sort of > noise). Is that the reason, or only reason to use CDATA section instead? > Comments are for commenting things out, CDATA sections are for including things. You can always replace a CDATA section by something else, but that's unlikely to be a comment. David > > -- > Regards, > Mukul Gandhi >