[jdom-interest] possible bug in removeContent()

Richard Cook rpc at prismtechnologies.com
Thu Jul 12 09:40:54 PDT 2001


in B7:

import org.jdom.*;

public class RemoveTest {
  RemoveTest() {
    Element e1 = new Element("fred");
    Document d = new Document(e1);
    Element e2 = new Element("jim");
    e1.addContent("t1");
    e1.addContent(e2);
    e1.addContent("t2");
    e1.removeContent(e2);
    java.util.Iterator it = e1.getContent().iterator();
    while (it.hasNext()) {
      System.out.println("..." + it.next());
    }
  }
  public static void main(String [] args) { new RemoveTest(); }

}

prints:

...t1
...t2

Should the consecutive text nodes be merged as per xml spec like when you do
addContent(), ie should the output be "...t1t2"



-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]On
Behalf Of Steven D. Keens
Sent: 12 July 2001 16:37
To: ted at longhairtech.com
Cc: jdom-interest
Subject: RE: [jdom-interest] Why no removeAllContent()?

But that only removes all child Elements.  It doesn't remove CDATA, PI, etc.

--
Steven Keens                mailto:skeens at planetfred.com
Planetfred Inc.             http://www.planetfred.com
44 Byward Market, Suite 240, Ottawa, ON, K1N 7A2, Canada

The most exciting phrase in science, the one which heralds
new discoveries, is not "Eureka!", but "That's funny!"
                       -- Isaac Asimov


>-----Original Message-----
>From: Ted Erickson [mailto:ted at longhairtech.com]
>Sent: Thursday, July 12, 2001 11:37
>To: 'Steven D. Keens'
>Subject: RE: [jdom-interest] Why no removeAllContent()?
>
>
>Um, I use Element.removeChildren() to remove all children.
>
>-----Original Message-----
>From: jdom-interest-admin at jdom.org
>[mailto:jdom-interest-admin at jdom.org]On Behalf Of Steven D. Keens
>Sent: Thursday, July 12, 2001 7:06 AM
>To: jdom-interest
>Subject: [jdom-interest] Why no removeAllContent()?
>
>
>Just a quick question:
>There are several remove...() methods but not one to clear all of the
>children.  I understand I can do it with setContent( null ) but that's not
>quite as clear as removeAllContent() or clear().  So why is there no
>removeAllContent() method?
>
>--
>Steven Keens                mailto:skeens at planetfred.com
>Planetfred Inc.             http://www.planetfred.com
>44 Byward Market, Suite 240, Ottawa, ON, K1N 7A2, Canada
>
>The most exciting phrase in science, the one which heralds
>new discoveries, is not "Eureka!", but "That's funny!"
>                       -- Issac Asimov
>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youradd
r at yourhos
t.com


_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list