[jdom-interest] SetIndent("") removes cariage returns

Jason Hunter jhunter at servlets.com
Mon Nov 13 21:17:39 PST 2006


Maverick Merritt wrote:
> 
> Hello,
> 
> I sent mail about a week ago asking if there was a way to create XML 
> output that had new lines (carriage return), but no indents... for example:
> 
> Format format = Format.getPrettyFormat();
> format.setIndent("");
> 
> But this removes new lines (carriage return) as well, which is what I 
> don't want.
> 
> Since no one responded...
> 
> 1) Is this the right list to bring up this issue?

Yes, this is the right list.

> 2) Is this something that has been addressed and cannot be changed?

It's done that way by design, but I won't argue very strongly that it's 
the right design.  Per the Format.setLineSeparator Javadocs:

  If the format's "indent" property is null or "" (as is the default
  for the Raw and Compact formats), then this value only effects the
  newlines written after the declaration and doctype.

I don't recall the justification for this behavior.  Perhaps it's that 
people wanted to have essentially compact output while still controlling 
newlines for the decl and doctype.

A fix to write newlines even when indent is null seems reasonable.  I 
suppose without any new props that change would eliminate the ability 
for people to have no newlines in the content (compact style) while 
having control of newline selection in the header portions.

Maverick, my recommendation right now is to just alter the XMLOutputter 
class to match what you want.  If others agree the change is useful 
enough, and that the backwards compatibility issues aren't worth 
stopping the change, then maybe you can submit a patch for inclusion.

-jh-


More information about the jdom-interest mailing list