SAX: Comments (question 7 of 10)

David Megginson ak117 at
Sat Jan 3 18:25:29 GMT 1998

[SAX is a proposal for a simple, event-based XML API, using
callbacks.  This is one in a series of ten design questions that we
need to answer to implement the API.]

Should SAX include an event for comments?

  public void comment (char ch[], int length);


- comments are purely lexical, and do not form an integral part of a
  document's information set for processing (as opposed to authoring
  or archiving);

- including comments in SAX might encourage comment abuses like those
  common in HTML (i.e. enclosing 800 lines of JavaScript in a


- the DOM includes comments in the core level-one implementation;

- HyTime uses comments for lexical constraints.



SAX is not designed for authoring tools or repositories, that need to
preserve the lexical as well as the logical structure of a document,
and there is no compelling reason to report comments here except for
DOM building (and we can always leave them out of a DOM).

The conventional comments in HyTime are not required, and personally,
I believe that they should not have been there in the first place.


Another lexical feature that I am not discussing here is CDATA
sections; I assume that, when the parser is reporting character data,
it does not matter how the parser obtained those characters (in a
CDATA section, or in regular #PCDATA with the delimiters escaped using
references).  I am happy, of course, to listen to other opinions on
this subject.

All the best,


David Megginson                 ak117 at
Microstar Software Ltd.         dmeggins at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as:
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list