[jdom-interest] XMLOutputter: extra white space inside tags

Chris Hostetter chrish at cnet.com
Fri Jun 22 12:05:58 PDT 2001

The XMLOutputter seems to be adding extra, unneccessary, white space after
the last attr/value pair in an Element, source is attached...

bester:~/code/java/jdom-bug> javac -classpath .:/usr/local/cnet/jdom/jdom-b6/build/jdom.jar:/usr/local/cnet/xerces/xerces-1_3_1/xerces.jar Bug.java
bester:~/code/java/jdom-bug> java -classpath .:/usr/local/cnet/jdom/jdom-b6/build/jdom.jar:/usr/local/cnet/xerces/xerces-1_3_1/xerces.jar Bug
 IN: <o><i p="v" p2="v2"/></o>
OUT: <o><i p="v" p2="v2" /></o>

-------------- next part --------------
import java.io.StringReader;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

public class Bug {

    public static String inputXml = "<o><i p=\"v\" p2=\"v2\"/></o>";
    public static void main(String argv[]) throws Exception {
	StringReader reader = new StringReader(inputXml);
	SAXBuilder builder = new SAXBuilder();
	Document doc = builder.build(reader);
	Element root = doc.getRootElement();

	XMLOutputter outputer = new XMLOutputter();
	String outputXml = outputer.outputString(root);

	System.out.println(" IN: " + inputXml);
	System.out.println("OUT: " + outputXml);

More information about the jdom-interest mailing list