[jdom-interest] org.jdom.JDOMException

Alex Rosen arosen at silverstream.com
Tue Apr 30 15:10:10 PDT 2002


> >I've a very simple question. I've a XML log file, this log contains all
the
> >activity from a Java application server. There're some cases, by example:
> >when the server has a fatal error, or the PC is shutdown or anything
else...
> >in such events the final end-tag is absent.
>
> Then the file does not contain an XML document, and it cannot be
> parsed by JDOM.  If you add the end-tag, then it will become a legal
> XML document, and you can parse it.

But if the app died in the middle of writing an element, the document still
would be bad.

As a hack, you could subclass SAXBuilder and override build(InputSource), so
that it returned contentHandler.getDocument() even if an exception occurred.
This would give you back whatever could be parsed before the bad part was
hit. Of course, this will happen for error that you're not expecting, not
just for errors that you are expecting...

Alex




More information about the jdom-interest mailing list