Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reset/Resuse XMLEventReader?

cshDec 11 2013 — edited Dec 11 2013

Hi,

I'd like to reuse or reset a XMLEventReader.

The problem:

xmlInputFactory.createXMLEventReader(inputStream);

is quite expensive, in my scenario up to 800ms.

The inputstream is created from a socket connection. The server socket sends XML data and sometimes "aborts" the XML structure in the middle and sends a new XML document. This is planned and I know when it happens.

But if I just reuse the XMLEventReader, it throws:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,395]

Message: Verarbeitungsanweisungsziel, das "[xX][mM][lL]" entspricht, ist nicht zulässig.

because the old XML document was not finished/closed, and the reader does not expect a new XML declaration.

If I just create a new XMLEventReader it works, but it is slow.

I also tried to use BufferedInputStreamReader and its reset and skip method, but I get exceptions, too.

Any ideas?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 8 2014
Added on Dec 11 2013
1 comment
1,537 views