W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: HRE when adding to Doc created with DTD

From: Joseph Kesselman <keshlam@us.ibm.com>
Date: Wed, 4 Apr 2001 09:23:55 -0400
To: James <jhughes@kos.net>
Cc: www-dom@w3.org
Message-ID: <OF7C5A94D5.0FD551F3-ON85256A24.0048E422@pok.ibm.com>

>I create my Document object like this:
>    ruledoc = new DocumentImpl();

You're probably aware of this, but that constructor is not portable --
you're explicitly accessing a specific implementation of the DOM, and you
then have to add the root element which is a slight violation of the DOM
architecture. It's better to use the DOMImplementation.createDocument()
call, which is portable and creates the Document and the root element
simultaneously. (Obtaining the DOMImplementation itself is still a
nonportable step, but that's a one-time operation.)


The first child of the Document is _NOT_ necessarily the root element.
If you're inadvertently trying to append rule to a comment, or to the
DocumentType node, the DOM will quite correctly tell you that this is not
acceptable. The fact that validation affects this suggests that it is the
DocumentType that's surprising you.

If you really want to do so, you can check this by printing out
but simply switching to
should fix the problem.

Joe Kesselman  / IBM Research
Received on Wednesday, 4 April 2001 09:24:00 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC