[jdom-interest] Document setMixedContent bug

Dan Sojka dan_sojka at centegy.com
Mon Nov 27 18:13:10 PST 2000

There is a bug in the org.jdom.Document setMixedContent() method. The
result is always an empty Document because the parameter "content" List
is being cleared instead of the "content" List field declared in the
class.  The bug was found in latest 11/27/00 daily snapshot

 public Document setMixedContent(List content) {
        content.clear(); // <<< should be this.content.clear().
        rootElement = null;

        for (Iterator i = content.iterator(); i.hasNext(); ) {
            Object obj = i.next();
            if (obj instanceof Element) {
            else if (obj instanceof Comment) {
            else if (obj instanceof ProcessingInstruction) {
            else {
                throw new IllegalAddException(
                    "A Document may contain only objects of type
Element, " +
                    "Comment, and ProcessingInstruction");

        return this;

More information about the jdom-interest mailing list