[jdom-interest] XMLOutputter error escaping this: element.addContent("");

Beau Bisquette Beau at PostTool.com
Sun Sep 3 14:40:01 PDT 2000


Dear Brett,

We have been experiencing difficulty outputting XML which has elements with 
empty content- not a new element with no content, but an element with "" 
content.
	ie: element.addContent(""); 		

so we propose this fix (or a more elegant rewrite...) starting at line 513 
of XMLOutputter,java

// Print the tag  with String on same line
// Example: tag name="value">content/tag>            			
// ** blows up if "" has been added as content to any element
// ** so we must test for funkiness.
// ** (david at posttool.com, will at posttool.com) String elementText = 
element.getText();
if ( ( elementText != null ) && !( elementText.equals( "" ) ) ) {
	out.write(">");
	out.write(escapeElementEntities(elementText));
	out.write("/");
	out.write(element.getQualifiedName());
	out.write(">");
} else {
	out.write(" />");
}
// end of test...

Thanks,
David & Will


Beau Bisquette
TPC Productions
Oakland, California




More information about the jdom-interest mailing list