[jdom-interest] Patch: JDOM white space probelm

Bradley S. Huffman hip at a.cs.okstate.edu
Wed Feb 26 13:14:48 PST 2003


For myself and most other users absolutely nothing, but a while back there
was a thread about not printing a line separator after the doctype.  This
just allows someone to do a kludge such as

    out.write("<?xml version=\"1.0\"?>");
    outputter.output(doctype, out);
    outputter.output(document.getRootElement(), out);

It doesn't effect the output of output(document, out) or any other output
method beyond output(doctype, out) so I don't mine being accommodating.

Brad

Jason Hunter writes:

> Brad, what's the purpose of moving up the line separator print?
> 
> -jh-
> 
> "Bradley S. Huffman" wrote:
> > 
> > Here's a patch to XMLOutputter that should fix the problem.  It
> > also moves the printing of line seperator after doctype up to
> > output(Document,Writer).
> > 
> > Since we don't have a unit test to throughly test XMLOutputter, try the
> > patch for a couple days and let's us know if it introduces any problems.
> > Right now I can only run it on a simple test, which seems to work just
> > fine.
> > 
> > Brad
> > 
> > *** XMLOutputter.old    Tue Feb 25 09:26:37 2003
> > --- XMLOutputter.java   Tue Feb 25 09:49:33 2003
> > ***************
> > *** 667,672 ****
> > --- 667,676 ----
> > 
> >           if (doc.getDocType() != null) {
> >               printDocType(doc.getDocType(), out);
> > +
> > +             // Always print line separator after declaration, helps the
> > +             // output look better and is semantically inconsequential
> > +             out.write(currentFormat.lineSeparator);
> >           }
> > 
> >           // Print out root element, as well as any root level
> > ***************
> > *** 1039,1048 ****
> >               out.write("]");
> >           }
> >           out.write(">");
> > -
> > -         // Always print line separator after declaration, helps the
> > -         // output look better and is semantically inconsequential
> > -         out.write(currentFormat.lineSeparator);
> >       }
> > 
> >       /**
> > --- 1043,1048 ----
> > ***************
> > *** 1522,1529 ****
> >           int size = content.size();
> >           if (currentFormat.trimAllWhite
> >                   || currentFormat.textNormalize
> > !                 || currentFormat.textTrim
> > !                 || currentFormat.newlines) {
> >               while( index < size) {
> >                   if ( !isAllWhitespace( content.get(index))) {
> >                       return index;
> > --- 1522,1528 ----
> >           int size = content.size();
> >           if (currentFormat.trimAllWhite
> >                   || currentFormat.textNormalize
> > !                 || currentFormat.textTrim) {
> >               while( index < size) {
> >                   if ( !isAllWhitespace( content.get(index))) {
> >                       return index;
> > ***************
> > *** 1547,1554 ****
> >           int index = start;
> >           if (currentFormat.trimAllWhite
> >                   || currentFormat.textNormalize
> > !                 || currentFormat.textTrim
> > !                 || currentFormat.newlines) {
> >               while( index >= 0) {
> >                   if ( !isAllWhitespace( content.get(index - 1)))
> >                       break;
> > --- 1546,1552 ----
> >           int index = start;
> >           if (currentFormat.trimAllWhite
> >                   || currentFormat.textNormalize
> > !                 || currentFormat.textTrim) {
> >               while( index >= 0) {
> >                   if ( !isAllWhitespace( content.get(index - 1)))
> >                       break;
> > _______________________________________________
> > To control your jdom-interest membership:
> > http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourho
> st.com
> 



More information about the jdom-interest mailing list