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

What characters can go into a CDATA section and a comment? (I foundincon

  • From: Roger L Costello <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Wed, 23 Mar 2022 11:39:48 +0000

What characters can go into a CDATA section and a comment? (I foundincon
Hi Folks,

I did some testing to see what characters can go into a CDATA section and a comment. Here's what I found:

Recall the CDATA syntax: <![CDATA[ ... ]]>

Question: Can the content of a CDATA section contain the ] character?

<![CDATA[foo]bar]]>

Answer: Yes

Question: Can the content of a CDATA section contain ]]?

<test><![CDATA[foo]]bar]]></test>

Answer: Yes.

Question: Can the content of a CDATA section contain more than two ] characters at the end?

<![CDATA[foo]]]]]>

Answer: Yes.

Question: Can the content of a CDATA section contain more than one [ character at the start?

<![CDATA[[[foo]]>

Answer: Yes.

Recall the comment syntax: <!-- ... -->

Question: Can the content of a comment contain a dash character?

<!-- foo - bar -->

Answer: Yes.

Question: Can the content of a comment contain two dashes?

<!-- foo -- bar -->

Answer: No.

Question: Can the content of a comment end with more than two dashes?

<!-- foo----->

Answer: No.

Notice the inconsistency: A CDATA section can end with more than two ] characters but a comment cannot end with more than two dashes:

<![CDATA[foo]]]]]>   	Okay
<!-- foo----->		Error

Also, a CDATA section can contain ]] but a comment cannot contain --

<![CDATA[foo]]bar]]>
<!-- foo -- bar -->

Why is there this inconsistency? 

Isn't inconsistency in a data format language bad?

/Roger



[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.