From: Nick Burch Date: Tue, 23 Feb 2016 22:24:09 +0000 (+0000) Subject: #59021 Namespace aware processing fix for ReadOnlySharedStringsTable, to match the... X-Git-Tag: REL_3_14_FINAL~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=22f6743fcafc403531876c0eee1d9f877cd08388;p=poi.git #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 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java index 14c04e53cd..b03c505a64 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.java @@ -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(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; } }