[jdom-interest] XML standard line ending

William Krick wkrick at eio-online.com
Thu Mar 11 13:00:05 PST 2004

I believe that System.getProperty("line.separator") should always be
used unless a file format mandates a specific line ending combination.


-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Rick Beton
Sent: Thursday, March 11, 2004 3:53 PM
To: jdom-interest at jdom.org
Subject: [jdom-interest] XML standard line ending

One thing that puzzles me is org.jdom.output.Format.java:128.  Why is 
the standard line ending CR NL?  It would be natural to use the machine 
default, i.e. .  The W3C Recommendations (*) specify that some 
combination of CR and NL must be used, but they are usually normalised 
to a single NL.  It makes sense therefore for line 128 to instead read:

    private static final String STANDARD_LINE_SEPARATOR = "\n";

java.io.PrintWriter uses the system property |line.separator to control 
the line endings.  This gives the following option:|
|    private static final String STANDARD_LINE_SEPARATOR = 

This would make XML documents generated by XMLOutputter into normal text 
files on whatever system they are created on, which would be generally 

What do folks think?

Rick :-)

XML1.0: http://www.w3.org/TR/2004/REC-xml-20040204
XML1.1: http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-line-ends
I consulted Format.java rev 1.7

More information about the jdom-interest mailing list