From: Dominik Stadler Date: Thu, 31 Dec 2015 09:56:33 +0000 (+0000) Subject: Fix bug 58760: non-standard namespace-key breaks parsing XLSX files X-Git-Tag: REL_3_14_FINAL~127 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4b37b0d47d96ad39aa3cb227d4935e6e463bb00a;p=poi.git Fix bug 58760: non-standard namespace-key breaks parsing XLSX files git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1722433 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index ecf30a677d..a23dbdd7cc 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -259,9 +259,6 @@ public class TestAllFiles { // non-TNEF files EXPECTED_FAILURES.add("ddf/Container.dat"); EXPECTED_FAILURES.add("ddf/47143.dat"); - - // will be fixed as part of bug 58760 - EXPECTED_FAILURES.add("spreadsheet/58760.xlsx"); } private static final Set IGNORED = new HashSet(); diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java index aed9bacb15..4d01e1ca78 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java @@ -320,7 +320,7 @@ public final class PackageRelationshipCollection implements // Check OPC compliance M4.1 rule boolean fCorePropertiesRelationship = false; - NodeList nodeList = root.getElementsByTagName(PackageRelationship.RELATIONSHIP_TAG_NAME); + NodeList nodeList = root.getElementsByTagNameNS(PackageNamespaces.RELATIONSHIPS, PackageRelationship.RELATIONSHIP_TAG_NAME); int nodeCount = nodeList.getLength(); for (int i = 0; i < nodeCount; i++) { Element element = (Element)nodeList.item(i); diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java index eb569e3a88..cc8550b903 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java @@ -377,7 +377,7 @@ public abstract class ContentTypeManager { Document xmlContentTypetDoc = DocumentHelper.readDocument(in); // Default content types - NodeList defaultTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagName(DEFAULT_TAG_NAME); + NodeList defaultTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagNameNS(TYPES_NAMESPACE_URI, DEFAULT_TAG_NAME); int defaultTypeCount = defaultTypes.getLength(); for (int i = 0; i < defaultTypeCount; i++) { Element element = (Element) defaultTypes.item(i); @@ -387,7 +387,7 @@ public abstract class ContentTypeManager { } // Overriden content types - NodeList overrideTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagName(OVERRIDE_TAG_NAME); + NodeList overrideTypes = xmlContentTypetDoc.getDocumentElement().getElementsByTagNameNS(TYPES_NAMESPACE_URI, OVERRIDE_TAG_NAME); int overrideTypeCount = overrideTypes.getLength(); for (int i = 0; i < overrideTypeCount; i++) { Element element = (Element) overrideTypes.item(i); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 870a8c4e5d..78b29cb104 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -2879,7 +2879,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { * ! Rule: Package require content types when retrieving a part from a package. [M.1.14] */ @Test - @Ignore public void test58760() throws Exception { Workbook wb = XSSFTestDataSamples.openSampleWorkbook("58760.xlsx"); assertEquals(1, wb.getNumberOfSheets());