[jdom-interest] XMLOutputter and newlines after declaration/doctype

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Dec 18 14:06:09 PST 2002


At 3:55 PM -0500 12/18/02, Vadim Strizhevsky wrote:

>I'd like to request an ability to output the whole xml as one line,
>without any newlines, (except the final one I guess). Either controlled
>by the same flag as other new lines or a separate boolean flag. While I
>do agree that having them there is sematically inconsequential, there
>are situations and non-semantic reasons when you may want to really have
>xml output as a single line. You want doc as small a possible.

Maybe 16 bytes difference at most? Only one or two bytes saved in 
most cases. I'm not willing to complexify the API for that small a 
gain

>Or you
>want to generating a big log file of multiple xml messages that will
>later be processes by scripts. Having the complete message on a single
>line would simplify those scripts.

No, it wouldn't; at least not if the scripts are using an XML parser; 
and if they're not why did you write the document in XML in the first 
place?

>For now I will have XMLOutputter subclass that duplicates
>printDeclaration and printDocType methods and doesn't print the newlines
>when newline option is set to false.

I suggest that's the appropriate solution here.

>Also I noticed a signle use  of "\n" instead of lineSeparator in the
>latest printDocType code.
>

Sounds like a bug that needs to be fixed. Probably not hard if CVS 
were up. Jools?
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
|              http://www.cafeconleche.org/books/xian2/              |
|  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list