W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1997

Re: Node.insert(idx, child) is not sufficient for

From: Laurent ROUVET <rouvet@cnam.fr>
Date: Mon, 29 Dec 1997 10:09:58 +0100
Message-ID: <34A768E6.E999B81@cnam.fr>
To: www-dom@w3.org, Alexandre Rafalovitch <arafalov@socs.uts.EDU.AU>
> Date: Sun, 26 Oct 1997 14:56:23 +1100 (EST)
> From: Alexandre Rafalovitch <arafalov@socs.uts.EDU.AU>
> To: www-dom@w3.org
> Message-ID: <Pine.SOL.3.95.971026144012.29998A-100000@charlie>
> Subject: Node.insert(idx, child) is not sufficient for building DOM.
> 
> Specification for Node is missing appendChild call, I believe.
> If you want to add a child at the end of the current children of the node,
> there are two ways to do it:
> 1) node.getChildren().append(newChild)
> 2) node.insert(100000, newChild)
> 
> The problem in first case is how and when to set the parent up. It is

You can add a method setParent(Node parent) at class Node and class
NodeList.

public class NodeList implement w3c.dom.NodeList {
private Node parent;

protected void setParent(Node parent) {this.parent = parent; }

public void append(Node child) {
   if (child != null) {
	child.setParent(parent);
	list.add(child);
   }
}


For your second PB, you can use Integer.MAX_VALUE

Look http://www.mygale.org/01/rouvet/en/dom
I did a simple implementation of the Java DOM interfaces to test.

Laurent.
Received on Monday, 29 December 1997 17:28:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:44 GMT