[jdom-commits] CVS update: jdom/src/java/org/jdom/output
jhunter at cvs.jdom.org
jhunter at cvs.jdom.org
Thu Dec 14 20:13:17 PST 2000
Date: Friday December 15, 2000 @ 4:13
Author: jhunter
Update of /home/cvspublic/jdom/src/java/org/jdom/output
In directory www.nmemonix.com:/tmp/cvs-serv5103
Modified Files:
XMLOutputter.java
Log Message:
Fixed bug where "additional namespace" declarations would be output even
if they were already declared by an ancestor.
Here's a hacked program and input file I used to demonstrate the bug for
myself.
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
public class NoAddl {
public static void main(String[] args) throws Exception {
XMLOutputter outputter = new XMLOutputter(" ", true);
outputter.setTrimText(true);
System.out.println("\n\nDOMBuilder from file:");
DOMBuilder domBuilder = new DOMBuilder();
Document doc2 = domBuilder.build(new File(args[0]));
System.out.println("\n\nDOM built tree");
outputter.output(doc2, System.out);
Iterator itr = doc2.getRootElement().getChildren().iterator();
while (itr.hasNext()) {
Element next = (Element) itr.next();
System.out.println(next);
Iterator itr2 = next.getChildren().iterator();
while (itr2.hasNext()) {
System.out.println(" " + itr2.next());
}
}
System.out.println("\n\nManipulating elements.....");
Namespace override = Namespace.getNamespace("ns1", "http://override");
Element root = doc2.getRootElement();
Element b = root.getChild("b");
Element kid = b.getChild("kid", override);
b.removeContent(kid);
root.getMixedContent().add(0, kid);
root.removeContent(b);
kid.addContent(b);
outputter.output(doc2, System.out);
itr = doc2.getRootElement().getChildren().iterator();
while (itr.hasNext()) {
Element next = (Element) itr.next();
System.out.println(next);
Iterator itr2 = next.getChildren().iterator();
while (itr2.hasNext()) {
System.out.println(" " + itr2.next());
}
}
}
}
<doc xmlns:ns1="http://1.2.3">
<ns1:a/>
<b xmlns:ns1="http://override">
<ns1:kid/>
</b>
<a/>
</doc>
-jh-
===================================================================
File: XMLOutputter.java Status: Up-to-date
Working revision: 1.32 Fri Dec 15 04:13:17 2000
Repository revision: 1.32 /home/cvspublic/jdom/src/java/org/jdom/output/XMLOutputter.java,v
Existing Tags:
start (revision: 1.1.1.1)
jdom (branch: 1.1.1)
More information about the jdom-commits
mailing list