Small Stax fixes.

This commit is contained in:
Arjen Poutsma 2010-09-08 08:42:09 +00:00
parent 6a4bc3e39f
commit f92f295055
2 changed files with 10 additions and 10 deletions

View File

@ -80,7 +80,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
StaxEventXMLReader(XMLEventReader reader) { StaxEventXMLReader(XMLEventReader reader) {
try { try {
XMLEvent event = reader.peek(); XMLEvent event = reader.peek();
if (event == null || !(event.isStartDocument() || event.isStartElement())) { if (event != null && !(event.isStartDocument() || event.isStartElement())) {
throw new IllegalStateException("XMLEventReader not at start of document or element"); throw new IllegalStateException("XMLEventReader not at start of document or element");
} }
} }
@ -146,7 +146,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
break; break;
} }
} }
if (!documentEnded) { if (documentStarted && !documentEnded) {
handleEndDocument(); handleEndDocument();
} }
@ -169,19 +169,19 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
getContentHandler().setDocumentLocator(new Locator2() { getContentHandler().setDocumentLocator(new Locator2() {
public int getColumnNumber() { public int getColumnNumber() {
return location.getColumnNumber(); return location != null ? location.getColumnNumber() : -1;
} }
public int getLineNumber() { public int getLineNumber() {
return location.getLineNumber(); return location != null ? location.getLineNumber() : -1;
} }
public String getPublicId() { public String getPublicId() {
return location.getPublicId(); return location != null ? location.getPublicId() : null;
} }
public String getSystemId() { public String getSystemId() {
return location.getSystemId(); return location != null ? location.getSystemId() : null;
} }
public String getXMLVersion() { public String getXMLVersion() {

View File

@ -143,19 +143,19 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
getContentHandler().setDocumentLocator(new Locator2() { getContentHandler().setDocumentLocator(new Locator2() {
public int getColumnNumber() { public int getColumnNumber() {
return location.getColumnNumber(); return location != null ? location.getColumnNumber() : -1;
} }
public int getLineNumber() { public int getLineNumber() {
return location.getLineNumber(); return location != null ? location.getLineNumber() : -1;
} }
public String getPublicId() { public String getPublicId() {
return location.getPublicId(); return location != null ? location.getPublicId() : null;
} }
public String getSystemId() { public String getSystemId() {
return location.getSystemId(); return location != null ? location.getSystemId() : null;
} }
public String getXMLVersion() { public String getXMLVersion() {