Small Stax fixes.

master
Arjen Poutsma 14 years ago
parent 6a4bc3e39f
commit f92f295055
  1. 12
      org.springframework.core/src/main/java/org/springframework/util/xml/StaxEventXMLReader.java
  2. 8
      org.springframework.core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java

@ -80,7 +80,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
StaxEventXMLReader(XMLEventReader reader) {
try {
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");
}
}
@ -146,7 +146,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
break;
}
}
if (!documentEnded) {
if (documentStarted && !documentEnded) {
handleEndDocument();
}
@ -169,19 +169,19 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
getContentHandler().setDocumentLocator(new Locator2() {
public int getColumnNumber() {
return location.getColumnNumber();
return location != null ? location.getColumnNumber() : -1;
}
public int getLineNumber() {
return location.getLineNumber();
return location != null ? location.getLineNumber() : -1;
}
public String getPublicId() {
return location.getPublicId();
return location != null ? location.getPublicId() : null;
}
public String getSystemId() {
return location.getSystemId();
return location != null ? location.getSystemId() : null;
}
public String getXMLVersion() {

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

Loading…
Cancel
Save