Browse Source

Small Stax fixes.

3.0.x
Arjen Poutsma 16 years ago
parent
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

12
org.springframework.core/src/main/java/org/springframework/util/xml/StaxEventXMLReader.java

@ -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() {

8
org.springframework.core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java

@ -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() {

Loading…
Cancel
Save