[jdom-interest] XMLOutputter modifications
    Lars Hoss 
    woeye at web.de
       
    Thu Jul 19 06:52:29 PDT 2001
    
    
  
Hi all!
Currently we are working on a project that uses jdom beta7 and
we are very happy with with tool because it speeds up
several tasks in our product enormously :-)
Unfortunaly it seems that XMLOutputter is adding to many newlines
in the output. For example if I have a well formatted XML document
and parse it with DOMBuilder, the output of XMLOutputter
will contain more newlines than the original XML document before.
After having a deeper look at the sourcecode I modified it
in the following way:
* lines 1191-1192 from
    else if (justOutput != CDATA.class &&
      justOutput != String.class) {
  to
    else if (justOutput != CDATA.class &&
      justOutput != String.class && justOutput != null && justOutput != Element.class) {
  
* lines 1196-1199 from
    printString(scontent, out);
    endedWithWhite = endsWithWhite(scontent);
    justOutput = String.class;
    wasFullyWhite = (scontent.trim().length() == 0);
  to
    if(!((scontent.length() == 1) && ("\r\n".indexOf(scontent.charAt(0)) != -1)))
    {
       printString(scontent, out);
       endedWithWhite = endsWithWhite(scontent);
       justOutput = String.class;
       wasFullyWhite = (scontent.trim().length() == 0);
    }
  
Afterwards it worked fine for many. All options such as
setTextNormalize(boolean), setNewlines(boolean) and so on
worked as I expected.
What do you think?
Yours,
Lars
--
mailto:woeye at web.de
icq: 19903263
    
    
More information about the jdom-interest
mailing list