// there is no way to know the current position(event) of
// XMLEventReader. peek() is the only way to know the next event.
// The next event on the input stream should be
// XMLStreamConstants.START_DOCUMENT or
// XMLStreamConstants.START_ELEMENT.
XMLEvent event = xmlEventReader.peek();
int eventType = event.getEventType();
if (eventType != XMLStreamConstants.START_DOCUMENT
&& eventType != XMLStreamConstants.START_ELEMENT) {
throw new IllegalStateException(
"StAXSource(XMLEventReader) with XMLEventReader "
+ "not in XMLStreamConstants.START_DOCUMENT or "
+ "XMLStreamConstants.START_ELEMENT state");
}
this.xmlEventReader = xmlEventReader;
systemId = event.getLocation().getSystemId();
}