XML comments and "--"

comments, xml

Solution

From the standards document:

http://www.w3.org/TR/REC-xml/#sec-comments

[Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor may, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string " -- " (double-hyphen) must not occur within comments.] Parameter entity references must not be recognized within comments.

Problem

``` <!-- here is some comment -- ^ | what can be here apart from '>'? ``` XML seems not to like '--' inside comments. I read somewhere that '--' switchs some modes inside `<! ... >` thing, but `<!-- -- -- -->` (even number of `--`s) seem to be invalid too. If it is some historic feature, what is "pro" part of it? ("contra" part is inability to have `--` in comments). What is the reason of complicating comment processing by not making just '-->' end of comment and allowing '--' inside?

Original source