Pedro Izecksohn wrote:
> 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 EmptyNodeList.java:
>
> 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;}
>
> }That looks absolutely correct. -- Chris Burdess "They that can give up essential liberty to obtain a little safety deserve neither liberty nor safety." - Benjamin Franklin
pgp2s47Pk6Aaf.pgp
Description: PGP signature
_______________________________________________ Classpath mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath

