Possible bug in the specification of createComment

Hi All,

As a piece of routine testing using the Python 2.5 binding to DOM, I
tried the following:

	elem.appendChild(doc.createComment("-->"))

The provided serializer toxml(), yields an XML document which is not
well formed. I.e. it contains the following:

	<!---->-->

Now this case is somewhat nastier than the createTextNode case, because
in the latter, the serializer can encode content using entity references
to avoid ill-formedness. Such an escaping mechanism is not obviously
possible in this case.

I've had some debate with Python guys as to where the bug lies. I see
the following possibilities:

1. It's simply a bug in my code, and the implementation is behaving
correctly in every respect. In this case the DOM specification should
include text warning about this case.

2. createComment should throw an exception if the text of the comment
contains the string "-->", which of course would require an amendment to
the specification.

3. The serializer (toxml, in this case) should throw an exception. As
far as I am aware, this would not require a change to the specification,
though it would be very helpful if a change was made to help
implementers get this right.

I look forward to discussing this further, and working out how to best
resolve this issue!

cheers,
Tom 
-- 
                                You are beautiful; but learn to work,
Dr Thomas Conway                      for you cannot eat your beauty.
conway@csse.unimelb.edu.au                      -- Congolese proverb

Received on Tuesday, 6 November 2007 16:25:45 UTC