[jdom-interest] XMLOutputer b5 seems to output differently than B4

Amy Lewis amyzing at talsever.com
Tue Oct 10 19:43:18 PDT 2000


Hmmm,

On Wed, Oct 11, 2000 at 12:37:45AM +0100, Dino Fancellu wrote:
>XMLOutputter outputter = new XMLOutputter("  ",true);
>outputter.setLineSeparator("\r"); // i.e. just a line feed

Actually, just a carriage return (CR).  LF == '\n'

>Now b5 outputs like b4 XMLOutputter()

That's quite odd, actually.  The default line separator on Windows is
"\r\n".  "\n" is unix, and "\r" is Macintosh ....

>B5 uses "\r\n" as the default line seperator, which leads to ugly
>formatting, well, on my Windows box anyway.

Hmmm.  It prolly ought to use System.getProperty.

>In fact b4 just did a out.println(), which of course uses the system
>line.seperator, so b4 could well have seperated
>lines differently on different boxes.

For portability:
outputter.setLineSeparator(System.getProperty("line.separator"));

That gets you the same behavior as PrintWriter.println().

>I do so cringe when things break from previous behaviour without a good
>explanation of how to unbreak it.

I don't think that it's quite fair to call this "breakage."
XMLOutputter has been immensely enhanced for b5.  This is *changed*
behavior, but it's ultimately more flexible than the previous result,
and requires only a couple of lines to implement (as you show above).

Amy!
-- 
Amelia A. Lewis          alicorn at mindspring.com          amyzing at talsever.com
The Bible contains six admonishments to homosexuals and three hundred sixty-
two admonishments to heterosexuals.  That doesn't mean that God doesn't love
heterosexuals.  It's just that they need more supervision.



More information about the jdom-interest mailing list