[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnu.xml.dom.DomText implements Text and NodeList.

From: Pedro Izecksohn
Subject: gnu.xml.dom.DomText implements Text and NodeList.
Date: Tue, 3 Jan 2006 19:13:37 -0400
User-agent: KMail/1.7.2

DomText implements Text and NodeList.

The problem is that method getLength() from interfaces NodeList and Text
 have different meanings.

Text.getLength() must return the text content length in characters.
NodeList.getLength() must return the number of nodes it contains.

From DOM Level 3 Core Specification:

"Some types of nodes ... are leaf nodes that cannot have anything below them
in the document structure."

"Text -- no children"

From "C.6.1 Infoset to Text Node" I understand that for any Text,
text.getChildNodes() must return a NodeList whose getLength() equals 0.

The problem appears in SableVM classpath because for gnu.xml.dom.DomNode, 
node.getChildNodes() returns itself.

My proposed solution is:

Add to gnu.xml.dom.DomText:

import org.w3c.dom.NodeList;

   * Returns an EmptyNodeList.
   * @author Pedro Izecksohn
  public NodeList getChildNodes()
  return (NodeList) new EmptyNodeList();

Add to gnu/xml/dom/ the file

package gnu.xml.dom;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

 * @author Pedro Izecksohn

public final class EmptyNodeList implements NodeList

  public EmptyNodeList () {}

  public final int getLength () {return 0;}

  public final Node item (int index) {return null;}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]