Re: Replacing the root element

Ron,

    4DOM passes these test cases.  Not matter how a node's children are
modified we always check to make sure it does not break any of the rules.  Ex.
"A document can have only one element", "A document cannot have text
children", "A processing Instruction cannot have element children", etc.

    It treats appending, inserting, and replaceing with a DF as a series of
operations.  Each one is validated as above.

Here is the output from my test script.  I can send you the script if you
would like.

[molson@arthur test_dom]$ python ron.py
Original Document
<ROOT>
</ROOT>
Case 1, replace with element
<ROOT2>
</ROOT2>
Case 2, replace with df (one child)
<ROOT3>
</ROOT3>
Case 3, replace with df (two children)
Traceback (innermost last):
  File "ron.py", line 40, in ?
    doc.replaceChild(df,thirdRoot);
  File "/usr/local/lib/python/DOM/Document.py", line 208, in replaceChild
    return NodeIMP.replaceChild(self,newChild,oldChild);
  File "/usr/local/lib/python/DOM/Node.py", line 155, in replaceChild
    self.replaceDocumentFragment(newChild, oldChild)
  File "/usr/local/lib/python/DOM/Node.py", line 253, in
replaceDocumentFragment
    self.appendDocumentFragment(frag);
  File "/usr/local/lib/python/DOM/Node.py", line 232, in
appendDocumentFragment
    self.appendChild(head)
  File "/usr/local/lib/python/DOM/Document.py", line 188, in appendChild
    raise DOM.DOMIF.DOMException(HIERARCHY_REQUEST_ERR);
DOM.DOMIF.DOMException: <DOM.DOMIF.DOMException instance at 811a928>

Mike

Ronald Bourret wrote:

> I just tried replacing the root element with:
>
> a) another element
> b) a fragment containing one element
> c) a fragment containing two elements
>
> What I expected was that (a) and (b) would succeed and (c) would fail.
>  (Remember that when you replace a node with a fragment, the children of
> the fragment and not the fragment itself are used.)  None of the five DOM
> implementations I tried got the results I expected.  Any opinions as to
> which (if any) is right and why?
>
> -- Ron Bourret
>
> RESULTS:
> Data Channel:
> (a) DOMException: A node is used in a different document than the one that
> created it.
> (b) DOMException: A node is used in a different document than the one that
> created it.
> (b) DOMException: A node is used in a different document than the one that
> created it.
>
> Docuverse:
> (a) root element replaced
> (b) DOMException (no message)
> (c) DOMException (no message)
>
> IBM:
> (a) root element replaced
> (b) root element replaced
> (c) root element replaced
>
> Oracle:
> (a) root element replaced
> (b) DOMException: Node of this type cannot be added
> (c) DOMException: Node of this type cannot be added
>
> Sun:
> (a) root element replaced
> (b) DOMException: This node isn't allowed there
> (c) DOMException: This node isn't allowed there

--
Mike Olson
Member Consultant
FourThought LLC
http://www.fourthought.com http://opentechnology.org


---

"No program is interesting in itself to a programmer. It's only interesting as
long
as there are new challenges and new ideas coming up." --- Linus Torvalds

Received on Friday, 23 April 1999 14:30:27 UTC