#59021 Namespace aware processing fix for ReadOnlySharedStringsTable, to match the one recently added to XSSFSheetXMLHandler

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1731986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2016-02-23 22:24:09 +00:00
parent 194fdfe162
commit d35942ca52

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.xssf.eventusermodel;
import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -193,7 +195,11 @@ public class ReadOnlySharedStringsTable extends DefaultHandler {
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
if ("sst".equals(name)) {
if (uri != null && ! uri.equals(NS_SPREADSHEETML)) {
return;
}
if ("sst".equals(localName)) {
String count = attributes.getValue("count");
if(count != null) this.count = Integer.parseInt(count);
String uniqueCount = attributes.getValue("uniqueCount");
@ -202,18 +208,22 @@ public class ReadOnlySharedStringsTable extends DefaultHandler {
this.strings = new ArrayList<String>(this.uniqueCount);
characters = new StringBuffer();
} else if ("si".equals(name)) {
} else if ("si".equals(localName)) {
characters.setLength(0);
} else if ("t".equals(name)) {
} else if ("t".equals(localName)) {
tIsOpen = true;
}
}
public void endElement(String uri, String localName, String name)
throws SAXException {
if ("si".equals(name)) {
if (uri != null && ! uri.equals(NS_SPREADSHEETML)) {
return;
}
if ("si".equals(localName)) {
strings.add(characters.toString());
} else if ("t".equals(name)) {
} else if ("t".equals(localName)) {
tIsOpen = false;
}
}