Monday, November 16, 2009

Why does XML not allow nested comments?

I hate the fact that XML doesn't allow nested comments! Since I have comments in almost every source file I write, and since I frequently want to disable portions of my code, I hit this problem a lot

I finally found out why they don't allow nested comments, or any "--" inside: the original SGML has some complicated rules about double-dashes and how they change the parsing inside a comment, and the XML spec mandates that XML docs are valid SGML, so it is more restrictive and says that XML cannot contain any double-dashes.

So, basically, I want to throttle whoever came up with this complication in SGML. Maybe the person to blame actually introduced this in a previous spec... but anyone who puts this kind of trickiness into a standard should be blacklisted from IT work permanently. Argh!

1 comment:

Anonymous said...

I have to agree!