]> source.dussan.org Git - poi.git/commitdiff
#59021 Namespace aware processing fix for ReadOnlySharedStringsTable, to match the...
authorNick Burch <nick@apache.org>
Tue, 23 Feb 2016 22:24:09 +0000 (22:24 +0000)
committerNick Burch <nick@apache.org>
Tue, 23 Feb 2016 22:24:09 +0000 (22:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1731986 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java

index 14c04e53cd50d408a50b10d6213a1a4f51bf91c7..b03c505a64455ba322100d74bdc3cf0b57e923d2 100644 (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;
         }
     }