[jdom-interest] Bug Fix Request for XMLOutput

Jason Hunter jhunter at servlets.com
Tue Sep 9 15:38:59 PDT 2003

That's a nice hack you've got there.  The reason we don't do as you say 
with "newline(out);" is because the prolog and doctype never are built 
with any whitespace around them, even in the likely event they had 
whitespace in the source document.  SAX strips it all out.  SAX just 
doesn't give any whitespace details outside the root element.

People generally want newlines after these things, so we write them.  We 
can't just write them if newlines are on, because if we did then in the 
default case  where newlines are turned off, we wouldn't write the 
whitespace in the prolog even though the input file had the whitespace. 
  People would write in all the time about ugly file output.

Our solution isn't better, but I consider it the lesser evil.  And it's 
nice there's a workaround if you really don't want the whitespace there. 
  We could add a special function setNewlinesInProlog() or something, 
but it doesn't seem to matter to most folks, esp if there's a workaround.


Eric Gravel wrote:

> The problem I have encountered with XMLOutput can be worked around.  I 
> simply find that
> it defeats the purpose of one of the class' method... unless I 
> misunderstood the purpose
> of the setNewlines(boolean) method.
> My understanding of the method is that no carriage return would be 
> outputted when writing
> JDOM elements including xml prologue and doctype.  Unfortunately, these 
> 2 items always
> had a new line printed after them. The solution that I found to work 
> around this issue was
> to set the newline character to be an empty string using 
> XMLOutput.setLineSeparator("");
> Looking at the XMLOutput.java file, I personally think that the code for 
> output(Document doc, Writer out)
> or actually anywhere that uses   
> "out.write(currentFormat.lineSeparator);" should be changed
> to read  "newline(out);".  Reason being that newline() checks to see if 
> the currentFormat class
> newlines field is set to true in order to output the lineSeperator field 
> value of the currentFormat class.
> This way, I could tell XMLOutput to setNewline(false) and no new line 
> would be used to output
> the document.
> Eric A. Gravel
> IT - Internet Development
> Java Programmer/Analyst
> 305-666-1861 Ext.7315
> Direct: 305-925-7315
> Eric.Gravel at IntervalIntl.com
> ------------------------------------------------------------------------
> This e-mail and any attached documentation is intended only for the use 
> of the individual or entity to which it is addressed and may contain 
> information that is privileged, confidential, and exempt from 
> disclosure. If any reader of this message is not the intended recipient 
> you are hereby notified that any dissemination, distribution or copying 
> of this communication is strictly prohibited. If you have received this 
> communication in error, please notify the sender immediately. Thank you.

More information about the jdom-interest mailing list