[jdom-interest] BUG: XMLOutputter inserts extra empty lines

kevin.schmidt at convergys.com kevin.schmidt at convergys.com
Wed Nov 21 12:16:13 PST 2001


I noticed this also.  I didnt know if it was a bug or not though...
I am using a much larger XML file and dont really want the blank lines.
     Please fix it!     ;v)
     -Kevin





Andriy Palamarchuk <apa3a at yahoo.com>@jdom.org on 11/21/2001 10:06:13 AM

Sent by:  jdom-interest-admin at jdom.org


To:   jdom-interest at jdom.org
cc:
Subject:  [jdom-interest] BUG: XMLOutputter inserts extra empty lines


When I read an XML file and save it back with
XMLOutputter the result document contains extra empty
lines before some closing tags which are on separate
lines.
However, there is no extra empty lines when I compose
exactly the same document as JDom object in code and
then print it with XMLOutputter. Obviously, this is
some problem in the outputter with handling space
between tags.

I use JDom Beta 7.

Please, let me know in case I missed something.
Is there any workaround for this problem?

Code which reads/writes XML:

SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(
    new File("employees.xml"));

XMLOutputter outputter = new XMLOutputter();
outputter.setNewlines(true);
outputter.setIndent(true);
outputter.setTextNormalize(true);
String docStr = outputter.outputString(doc);
System.out.println(docStr);

The original XML file:
<?xml version="1.0" encoding="UTF-8"?>

<employees>
  <employee id="1" title="developer"
first-name="first-name1" last-name="last-name1">
    <picture>apalamarchuk.jpeg</picture>
    <profile>Design, coding, debugging; goto
design;</profile>
  </employee>
  <employee id="2" title="developer"
first-name="first-name2" last-name="last-name2">
    <picture>mmiller.jpeg</picture>
    <profile>Design, coding, debugging, riding bike;
goto design;</profile>
  </employee>
  <employee id="3" title="manager"
first-name="first-name3" last-name="last-name3">
    <picture>mbaara.jpeg</picture>
    <profile>Manage employees 1 and 2.</profile>
  </employee>
</employees>

The resulting XML file:
<?xml version="1.0" encoding="UTF-8"?>
<employees>
  <employee id="1" title="developer"
first-name="first-name1" last-name="last-name1">
    <picture>apalamarchuk.jpeg</picture>
    <profile>Design, coding, debugging; goto
design;</profile>

  </employee>
  <employee id="2" title="developer"
first-name="first-name2" last-name="last-name2">
    <picture>mmiller.jpeg</picture>
    <profile>Design, coding, debugging, riding bike;
goto design;</profile>

  </employee>
  <employee id="3" title="manager"
first-name="first-name3" last-name="last-name3">
    <picture>mbaara.jpeg</picture>
    <profile>Manage employees 1 and 2.</profile>

  </employee>

</employees>



__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



--

NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected.





More information about the jdom-interest mailing list