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

Etienne Gagnon <[email protected]> Tue, 03 Jan 2006 15:09:07 -0500
Newsgroups gmane.comp.java.vm.sablevm.general
Message-ID <[email protected]>
Hi Pedro,

This code is part of the class libraries.  Please submit this proposal
upstream, at the GNU Classpath project mailing-list: [email protected] .

Thanks, and good luck!

Etienne

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 is 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 any 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;}
> 
> }
> 
> _______________________________________________
> SableVM-user mailing list
> [email protected]
> http://sablevm.org/lists/control/listinfo/sablevm-user
> 
> 

-- 
Etienne M. Gagnon, Ph.D.            http://www.info2.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/

_______________________________________________
SableVM-user mailing list
[email protected]
http://sablevm.org/lists/control/listinfo/sablevm-user
signature.asc (application/pgp-signature, 256 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDutnjjyrJi4rH84gRAiXJAJwOz+D6v0K41UpzWnFli/3S44geUwCfdO23
irumSIW7eIqd1VBjpNBeAFY=
=olWO
-----END PGP SIGNATURE-----