提交 f92f2950 编写于 作者: A Arjen Poutsma

Small Stax fixes.

上级 6a4bc3e3
...@@ -80,7 +80,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader { ...@@ -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 { ...@@ -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 { ...@@ -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() {
......
...@@ -143,19 +143,19 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader { ...@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册