[jdom-interest] XMLOutputter Problem?

John L. Webber - intraWeb IT GmbH John.Webber at intraweb.de
Wed Aug 23 06:05:58 PDT 2000


I'm having a problem using XMLOutputter in connection with a pair of
PipedStreams. Basically what I'm trying to do is convert the output to a
string which I then display in a separate frame.

The problem seems to occur when my JDOM document exceeds a minimum size.
If the base XML file is only 12 lines or so, there's no problem, but
with the file shown below which is somewhat longer, XMLOutputter seems
to freeze indefinitely.

Has anyone run into a similar problem? I checked the list archives to no
avail.

Java code and XML file below.

Thanks,

John

>>XML file<<

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE unitset SYSTEM "unitset.dtd">



<unitset>
  <unit level="0" name="Jentro" type="unknown">
    <unit level="1" name="Lab" type="unknown">
      <unit level="2" name="Oldie" type="kiosk" x="12" y="23">
        <options ip="192.1.1.150" />
      </unit>
      <unit level="2" name="Netbreeze" type="kiosk" x="44" y="55">
        <options ip="192.1.1.171" />
      </unit>
    </unit>
    <unit level="1" name="Graphics1" type="unknown" />
    <unit level="1" name="Graphics2" type="unknown" />
    <unit level="1" name="Graphics3" type="unknown" />
    <unit level="1" name="Graphics4" type="unknown" />
    <unit level="1" name="Graphics5" type="unknown" />
    <unit level="1" name="Graphics6" type="unknown" />
    <unit level="1" name="Graphics7" type="unknown" />
    <unit level="1" name="Graphics8" type="unknown" />
    <unit level="1" name="Graphics9" type="unknown">
      <unit level="2" name="Graphics10" type="kiosk" x="1" y="2">
        <options ip="1.1.1.1" />
      </unit>
      <unit level="2" name="Graphics11" type="kiosk" x="1" y="2">
        <options ip="1.1.1.2" />
      </unit>
      <unit level="2" name="Graphics12" type="kiosk" x="1" y="2">
        <options ip="1.1.1.3" />
      </unit>
      <unit level="2" name="Graphics13" type="kiosk" x="1" y="2">
        <options ip="1.1.1.4" />
      </unit>
      <unit level="2" name="Graphics14" type="kiosk" x="1" y="2">
        <options ip="1.1.1.5" />
      </unit>
      <unit level="2" name="Graphics15" type="kiosk" x="1" y="2">
        <options ip="1.1.1.6" />
      </unit>
      <unit level="2" name="Graphics16" type="kiosk" x="1" y="2">
        <options ip="1.1.1.7" />
      </unit>
      <unit level="2" name="Graphics17" type="kiosk" x="1" y="2">
        <options ip="1.1.1.8" />
      </unit>
      <unit level="2" name="Graphics18" type="kiosk" x="1" y="2">
        <options ip="1.1.1.9" />
      </unit>
      <unit level="2" name="Graphics19" type="kiosk" x="1" y="2">
        <options ip="1.1.1.10" />
      </unit>
    </unit>
  </unit>
</unitset>

>>Java code (excerpt)>>

  public void displayDoc()
  throws IOException
{
  final StringBuffer buffer = new StringBuffer();
  XMLOutputter xmlOut = new XMLOutputter();
  PipedOutputStream pipedOut = new PipedOutputStream();
  PipedInputStream pipedIn = new PipedInputStream(pipedOut);
  final BufferedReader reader = new BufferedReader(new
InputStreamReader(pipedIn));
  xmlOut.output(doc, pipedOut);
  //The next line is never reached! 
  System.out.println("Output finished");
  pipedOut.close();
  Runnable readerThread = new Runnable() {
      public void run() {
        String temp;
        try
        {
          while ( (temp = reader.readLine()) != null)
          {
             buffer.append(temp);
          }
        }
        catch (IOException io) { }
      }
   };
   Thread t = new Thread(readerThread);
   t.start();
   String xmlResult = buffer.toString();
   System.out.println(xmlResult);


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intraWeb Information Technologies GmbH
John L. Webber, Software Development
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Peter-Henlein-Strasse 28-30, 85540 Haar/Munich, Germany
Tel.:  +49 89 462 385 0     (switchboard)
Tel.:  +49 89 462 385 38    (direct)
Fax:   +49 89 462 385 29
mailto:John.Webber at intraWeb.de
http://www.intraWeb.de
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the jdom-interest mailing list