-0.5<div><br></div><div>Since this is Java-DOM, I would choose the line separator used by Java apps, which in Java5 can be obtained from String.format("%n") -- or from System.getProperty("line.separator") in classic Java.</div>
<div><br></div><div>OTOH, since the rationale for choosing this separator hasn't changed since it was originally selected, I lean toward not changing it.</div><div><br></div><div>Joe</div><div><br><div class="gmail_quote">
On Tue, Nov 15, 2011 at 1:17 AM, Michael Kay <span dir="ltr"><<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The only real case I can see for using \r\n is that if you use \n, you can't view the output in Notepad (and presumably a few other diehard Windows applications).<br>
<br>
Making a change will break a few people's unit tests, but no real applications should be dependent on the precise bitstream.<br>
<br>
Using \r\n does seem a bit quirky, but I can't see that it does any harm.<br>
<br>
-0, if that's an allowed vote.<span class="HOEnZb"><font color="#888888"><br>
<br>
Michael Kay<br>
Saxonica</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 15/11/2011 01:29, Rolf wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all.<br>
<br>
JDOM has been merrily using "\r\n" as an end-of-line sequence in the XMLOutputer since 'forever'. The XML Spec indicates that all end-of-line sequences should be normalized to a single '\n': <a href="http://www.w3.org/TR/REC-xml/#sec-line-ends" target="_blank">http://www.w3.org/TR/REC-xml/#<u></u>sec-line-ends</a> The wording is such that XML parsers should clear out any extra '\r' characters if there are any, so it is not as if the code is completely broken.<br>
<br>
But, I think it makes sense to follow the spec, and avoid having different XML compared to other systems.<br>
<br>
I propose changing the line separator to follow the spec, but this has a very large impact on anyone who has expectations on JDOM having a particular line-terminator, even though they shouldn't...<br>
<br>
I have filed <a href="https://github.com/hunterhacker/jdom/issues/53" target="_blank">https://github.com/<u></u>hunterhacker/jdom/issues/53</a><br>
<br>
The original decision was made by Elliotte: <a href="http://markmail.org/message/gv7m3xjgrkomrfe7" target="_blank">http://markmail.org/message/<u></u>gv7m3xjgrkomrfe7</a> (it's worth noting that it was changed from the 'platform default' to the constant '\r\n' to create some consistency too).<br>
<br>
vvv quote vvv<br>
<br>
The one open question in this version is what to use for a line separator. Right now I'm using \r\n since that's most cross-platform compatible and friendliest to various network protocols. However, \n alone might be slightly friendlier to XML parsers. Another possibility is to ask for System.getProperty("line.<u></u>separator"). However, I'm loathe to make the output platform dependent. What do people think?<br>
<br>
^^^ quote ^^^<br>
<br>
Also, the commit introducing this has interesting comments: <a href="https://github.com/hunterhacker/jdom/commit/958fb22a4c7088b82f0d48a933bdf4e5c6806151#L0R173" target="_blank">https://github.com/<u></u>hunterhacker/jdom/commit/<u></u>958fb22a4c7088b82f0d48a933bdf4<u></u>e5c6806151#L0R173</a><br>
<br>
Two issues I see:<br>
1. "\r\n" was chosen for 'Network protocol' friendliness... is this still a valid argument?<br>
<br>
2. is it OK to change the standard format of all the XML that JDOM produces? (I have been really careful (so far) for the most part to ensure all whitespace (including indents and EOL/EOF is not changed) ).<br>
<br>
I see changing the default EOL as being an easy decision, especially since users can still change it back easily on their Format instance.<br>
<br>
advantages:<br>
1. Most XML tools do not use "\r" values - better compatibility?<br>
2. XML output will be slightly smaller - ;-)<br>
3. XML produced by 'other' outputters (currently the StAX outputters) can be compared directly with XMLOutputter for testing/compatibility<br>
<br>
disadvantages:<br>
1. people may have 'baselines' that contain \r\n terminators, which will then be different from JDOM's default output.<br>
2. there may be some (obscure) protocols that require \r\n terminators and users of JDOM2 will have to override the EOL to be '\r\n' for those.<br>
<br>
Anyone have comments/suggestions?<br>
<br>
Rolf<br></blockquote></div></div></blockquote></div></div>