Problem solve Get help with specific problems with your technologies, process and projects.

In XML comments, two consecutive -- are not allowed. Why?

In XML comments, two consecutive -- are not allowed. Why?
This restriction dates back to the SGML days.
In SGML, the comment start string "<!-- hello world-->" is actually a combination of five things. The first bit is "<!" and is known as "Markup declaration open" or "mdo" for short. The second bit is "--" and is known as "comment delimiter" or "com" for short. Then comes the string "hello world". The fourth piece is "--" which is "com" again. The final, fifth piece is ">" which is known as "markup declaration close" or mdc for short.

In SGML the full comment "<!-- hello world -->" is seen by the parser as:
MDO COM hello world COM MDC.

So, the reason for the restriction on "--" is that as far as the parsing rules are concerned, the "--" is the delimiter of a comment and so cannot occur within one.

Consideration was taken to removing this restriction during the early days of discussions about the shape of XML but it was decided to leave it as is eventually.

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.