Morten Primdahl wrote:
>
> but in CoreDocumentImpl.java I found:
>
> super.insertBefore(newChild,refChild);
>
> // If insert succeeded, cache the kid appropriately
> if (type == Node.ELEMENT_NODE) {
> docElement = (ElementImpl)newChild;
> }
>
In the code just above the snippet u pointed out, a check has been made
to see if the node to be inserted is an Element node or DocType node
and whether such a node already exists and if so, gives an error.
// Only one such child permitted
int type = newChild.getNodeType();
if (errorChecking) {
if((type == Node.ELEMENT_NODE && docElement != null) ||
(type == Node.DOCUMENT_TYPE_NODE && docType != null)) {
throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
"DOM006 Hierarchy request error");
}
}
> And ParentNode seems to indeed insert the child. So a document
> can have multiple children? The element returned by getDocumentElement
> returns the docElement, but should a such be able to have siblings?
> There should only be one top level element to my understanding. What
> am I missing here?
At most one top-level Element and at most one DocumentType declaraction
are allowed and insertBefore() checks for that before inserting.
-Pavani
--
Pavani Mukthipudi
Sun Microsystems, Inc.
Phone: 080 - 2298989 Extn: 87390
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]