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 09:18, Mukul Gandhi 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 &lt;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 &lt;title></title>
> </foo>-->
> </programlisting>

Technically, that might work, although getting it to display in a 
browser without programming might be challenging. IMHO this would be a 
form of tag abuse. Source code listings are not comments. There is 
always a balance to be struck when settling upon a way of doing things, 
to "keep the mean between the two extremes, of too much stiffness in 
refusing, and of too much easiness in admitting any variation" from it.

> 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?

XML comments are for the author, editor, programmer, developer or other 
user to be alerted to some condition that is not to be shown to the end 
user, eg

<programlisting language="XML"><!--
   Be aware that the DTD shown in this example
   SHOULD NOT be dereferenced during processing as
   it is an example only. --><![CDATA[
<?xml version="1.0">
<!DOCTYPE foo SYSTEM "bar.dtd">
<foo>
     <title>Some &lt;title></title>
</foo>
]]></programlisting>

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.