[jdom-interest] Default line separator in XMLOutputter

Stephan Trebels stephan at ncube.de
Wed Apr 16 06:31:10 PDT 2003


AFAIK, in XML it is defined not to make any difference. The XML code
should be represented faithfully, but the serialized XML can be any
valid string, that will create the same JDOM doc. 

In HTTP/1.1 the line end protocol of content is not defined at all.  The
line end characters are only defined for the headers and even there they
are typically tolerated in implementations.  For JDOM I don't see any
argument pro/con to be derived from HTTP or related protocols.

I personally don't think it is overly important to have binary identical
files across platforms if the JDOM representation is the same.  I use no
line endings in real usage, same as everyone else probably, as I want
the serialized XML to be small. 

But if I decide to pretty-print for debugging, I'd expect to get
File.separator, not MSDOS line-endings. This is _my_ personal
expectation, but the principle of least astonishment applies probably. 
Wat does surprise people less ;-)  

If needed we can still subclass XMLOutputter... 

On Wed, 2003-04-16 at 15:41, Elliotte Rusty Harold wrote:
> >Does anyone know why the line separator (STANDARD_LINE_SEPARATOR) 
> >default value is set to "\r\n" in XMLOutputter rather than using the 
> >platform default (system property "line.seperator")?
> 
> 
> 1. It's more interoperable across platforms to specify a line end 
> separator. Code that uses XMLOutputter should not produce different 
> output depending on which platform it's run on.
> 
> 2. \r\n is the standard line ending convention of most network 
> protocols such as HTTP.
-- 
        Stephan Trebels <stephan at ncube.de>   Consultant
company: nCUBE Deutschland GmbH, Hanauer Str. 56, 80992 Munich, Germany
phone: cell:+49 172 8433111  office:+49 89 1498930  fax:+49 89 14989350





More information about the jdom-interest mailing list