[XML-SIG] comments and -- in SAX

Fred L. Drake, Jr. fdrake@acm.org
Tue, 23 Jul 2002 02:02:07 -0400


Mike F Miller writes:
 > Is this legal XML and SAX is legitimately complaining or am I doing
 > something that's illegal in my XML comments?
...
 > <!-- bla bla bla   -->
 > <!-- bla bla bla   -->
 > <!--    --shawn    -->

David Niergarth writes:
 > Sorry, but neither SGML nor XML allow '--' to appear in the body of a
 > comment.

David's right, but I will point out that SGML has a slightly more
complex behavior than XML.  In XML, the -- is simply not allowed in
comment "content", while SGML allows multiple pairs of -- ... -- to
delimit "chunks" of comment content:

<!--  first line   --
  --  second line  -- >

If you've seen this in SGML, but don't know SGML's syntax rules deeply
enough, it can throw you for a loop the first time the distinction
pops up.

Mike's specific example is illegal in both XML and SGML, however.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation