Re: The phrase: Node created by Document needs clarification

I believe the current phrasing is adequate and generally understood.

> Methods: appendChild, insertBefore etc.
>      WRONG_DOCUMENT_ERR: Raised if newChild was created
>      from a different document than the one that created this node.
>
> Does it explicitly  mean that  the following condition:
> (parentNode.ownerDocument  == newChild.ownerDocument)
> is the ONLY condition that proves  that  parent and child node were
created
> from the same  document.

Actually, there is nothing in the DOM spec that ensures that identity
comparision between nodes is meaningful.  DOM L3 is considering adding an
isSameNode() function to allow node identity comparisons.  A node can be
appropriate and the condition can be true (likely) or false (less likely)
and a node can be inappropriate and the condition true (less likey) or false
(likely).


> In other words, may it be any other hidden conditions that do not belong
to
> the www.w3.org DOM Level 2 specification
> but the concrete implementation of DOM uses to check whether a newChild
was in
> fact created from this Document
>
> For example:
> XERCES 1.2 and 2.0 demands that newChild  was an instance of the class
> NodeImpl, otherwise
> newChild can not be appended to the parent node even if
> parentNode.getOwnerDocument()  == newChild.getOwnerDocument()

Xerces knows that any node object that was created by the document (either
through a call to a document create* method or returned by a public method)
will implement NodeImpl and instanceOf NodeImpl is false, it is certain that
the node was not created by the document but is from another implementation.

Any object that implements org.w3c.dom.Node but isn't an subclass of
org.apache.xerces.NodeImpl was not created by the Document.

>
> Is it correct in terms of DOM specification?
>
Passing an object from a different implementation is more than just a wrong
document and a different type of exception is not unexpected.

The public interfaces do not attempt to interfaces that would allow you to
provide your own implementation of Node.

p.s. Just an interested observer, not a W3C or DOM WG member

Received on Thursday, 30 August 2001 01:01:51 UTC