XHTML 1.0: Comment processing

Dear HTML Working Group,

  Appendix C.4 of XHTML 1.0 Second Edition reads

[...]
  Use external style sheets if your style sheet uses < or & or ]]> or
  --. Use external scripts if your script uses < or & or ]]> or --. Note
  that XML parsers are permitted to silently remove the contents of
  comments. Therefore, the historical practice of "hiding" scripts and
  style sheets within "comments" to make the documents backward
  compatible is likely to not work as expected in XML-based user agents.
[...]

Section 3.2 of the First Edition additionally contained

[...]
  In elements where the 'xml:space' attribute is set to 'preserve', the
  user agent must leave all whitespace characters intact (with the
  exception of leading and trailing whitespace characters, which should
  be removed). Otherwise, whitespace is handled according to the
  following rules: 

  [...]

    * Comments are removed entirely and do not affect whitespace
      handling. One whitespace character on either side of a comment
      is treated as two white space characters. 
[...]

This suggests that comments like in e.g.

  <p><!--...--></p>

would not be available in the DOM or to other means, while

  <style type="text/css"><!--...--></style>

would be available. Could you please clarify whether this is the
intention of the text and if, whether this still holds true under
the second edition and if not why this has been changed? It appears
that the requirement is misplaced in the first edition as it seems
a more general rule... But then I would question the utility of
mandating the removal of comment nodes at parse time...

I am not sure how to understand Appendix C.4, I would expect that
XHTML 1.0 is defined so that the content of comments is not to be
processed in any way other than described in the XML 1.0 Recommendation,
which means that XHTML 1.0 User Agents must not make scripts or style
sheets "hidden" in such a way "work as expected". Could you please
clarify under what circumstances other than non-conformance of a user
agent a style sheet inside a comment inside a <style> element would be
applied to the document?

regards.

Received on Friday, 28 May 2004 13:47:10 UTC