From 22f6743fcafc403531876c0eee1d9f877cd08388 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 23 Feb 2016 22:24:09 +0000 Subject: [PATCH] #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 --- .../ReadOnlySharedStringsTable.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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; } } -- 2.39.5