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?