poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1549007 - in /poi/trunk: src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java test-data/spreadsheet/55850.xlsx
Date Sun, 08 Dec 2013 08:35:20 GMT
Author: centic
Date: Sun Dec  8 08:35:20 2013
New Revision: 1549007

URL: http://svn.apache.org/r1549007
Log:
Bug 55850: fix NullPointerException during extraction from XSSF

Added:
    poi/trunk/test-data/spreadsheet/55850.xlsx
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=1549007&r1=1549006&r2=1549007&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Sun Dec  8
08:35:20 2013
@@ -41,11 +41,11 @@ import javax.xml.validation.SchemaFactor
 import javax.xml.validation.Validator;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.apache.poi.xssf.usermodel.XSSFTable;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFMap;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFTable;
 import org.apache.poi.xssf.usermodel.helpers.XSSFSingleXmlCell;
 import org.apache.poi.xssf.usermodel.helpers.XSSFXmlColumnPr;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STXmlDataType;
@@ -476,7 +476,7 @@ public class XSSFExportToXml implements 
         if (!"".equals(complexTypeName)) {
             NodeList  complexTypeList  = xmlSchema.getChildNodes();
             for(int i=0; i< complexTypeList.getLength();i++) {
-                Node node = list.item(i);
+                Node node = complexTypeList.item(i);
                 if ( node instanceof Element) {
                     if (node.getLocalName().equals("complexType")) {
                         Node nameAttribute  = node.getAttributes().getNamedItem("name");
@@ -504,4 +504,4 @@ public class XSSFExportToXml implements 
         }
         return complexTypeNode;
     }
-}
+}
\ No newline at end of file

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java?rev=1549007&r1=1549006&r2=1549007&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java Sun
Dec  8 08:35:20 2013
@@ -176,4 +176,42 @@ public final class TestXSSFExportToXML e
 			}
 		}
 	}
+
+    public void test55850ComplexXmlExport() throws Exception {
+
+        XSSFWorkbook wb = XSSFTestDataSamples
+                .openSampleWorkbook("55850.xlsx");
+
+        for (POIXMLDocumentPart p : wb.getRelations()) {
+
+            if (!(p instanceof MapInfo)) {
+                continue;
+            }
+            MapInfo mapInfo = (MapInfo) p;
+
+            XSSFMap map = mapInfo.getXSSFMapById(2);
+
+            assertNotNull("XSSFMap is null", map);
+
+            XSSFExportToXml exporter = new XSSFExportToXml(map);
+            ByteArrayOutputStream os = new ByteArrayOutputStream();
+            exporter.exportToXML(os, true);
+            String xmlData = os.toString("UTF-8");
+
+            assertNotNull(xmlData);
+            assertTrue(!xmlData.equals(""));
+
+            String a = xmlData.split("<A>")[1].split("</A>")[0].trim();
+            String b = a.split("<B>")[1].split("</B>")[0].trim();
+            String c = b.split("<C>")[1].split("</C>")[0].trim();
+            String d = c.split("<D>")[1].split("</Dd>")[0].trim();
+            String e = d.split("<E>")[1].split("</EA>")[0].trim();
+
+            String euro = e.split("<EUR>")[1].split("</EUR>")[0].trim();
+            String chf = e.split("<CHF>")[1].split("</CHF>")[0].trim();
+
+            assertEquals("15", euro);
+            assertEquals("19", chf);
+        }
+    }
 }

Added: poi/trunk/test-data/spreadsheet/55850.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/55850.xlsx?rev=1549007&view=auto
==============================================================================
Files poi/trunk/test-data/spreadsheet/55850.xlsx (added) and poi/trunk/test-data/spreadsheet/55850.xlsx
Sun Dec  8 08:35:20 2013 differ



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message