poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1577907 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/extractor/ testcases/org/apache/poi/xssf/extractor/
Date Sat, 15 Mar 2014 17:29:17 GMT
Author: centic
Date: Sat Mar 15 17:29:17 2014
New Revision: 1577907

URL: http://svn.apache.org/r1577907
Log:
Bug 56169: Fix NPE during export to XML with xs:all

Added:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java.orig
      - copied, changed from r1577901, poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java.orig
      - copied, changed from r1577901, 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
    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=1577907&r1=1577906&r2=1577907&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 Sat Mar 15
17:29:17 2014
@@ -261,7 +261,6 @@ public class XSSFExportToXml implements 
      * @return true, if document is valid
      */
     private boolean isValid(Document xml) throws SAXException{
-        boolean isValid = false;
         try{
             String language = "http://www.w3.org/2001/XMLSchema";
             SchemaFactory factory = SchemaFactory.newInstance(language);
@@ -270,14 +269,14 @@ public class XSSFExportToXml implements 
             Schema schema = factory.newSchema(source);
             Validator validator = schema.newValidator();
             validator.validate(new DOMSource(xml));
+            
             //if no exceptions where raised, the document is valid
-            isValid=true;
-
-
+            return true;
         } catch(IOException e) {
             e.printStackTrace();
         }
-        return isValid;
+
+        return false;
     }
 
 
@@ -517,7 +516,7 @@ public class XSSFExportToXml implements 
                             Node sequence = complexTypeChildList.item(j);
 
                             if ( sequence instanceof Element) {
-                                if (sequence.getLocalName().equals("sequence")) {
+                                if (sequence.getLocalName().equals("sequence") || sequence.getLocalName().equals("all"))
{
                                     complexTypeNode = sequence;
                                     break;
                                 }

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java.orig (from
r1577901, 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.orig?p2=poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java.orig&p1=poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java&r1=1577901&r2=1577907&rev=1577907&view=diff
==============================================================================
    (empty)

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=1577907&r1=1577906&r2=1577907&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 Sat
Mar 15 17:29:17 2014
@@ -361,6 +361,40 @@ public final class TestXSSFExportToXML e
        assertTrue(found);
    }
 
+   public void testXmlExportSchemaWithXSAllTag_Bugzilla_56169() throws Exception {
+       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56169.xlsx");
+
+       for (XSSFMap map : wb.getCustomXMLMappings()) {
+           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 a_b = a.split("<B>")[1].split("</B>")[0].trim();
+           String a_b_c = a_b.split("<C>")[1].split("</C>")[0].trim();
+           String a_b_c_e = a_b_c.split("<E>")[1].split("</EA>")[0].trim();
+           String a_b_c_e_euro = a_b_c_e.split("<EUR>")[1].split("</EUR>")[0].trim();
+           String a_b_c_e_chf = a_b_c_e.split("<CHF>")[1].split("</CHF>")[0].trim();
+
+           assertEquals("1", a_b_c_e_euro);
+           assertEquals("2", a_b_c_e_chf);
+
+           String a_b_d = a_b.split("<D>")[1].split("</Dd>")[0].trim();
+           String a_b_d_e = a_b_d.split("<E>")[1].split("</EA>")[0].trim();
+
+           String a_b_d_e_euro = a_b_d_e.split("<EUR>")[1].split("</EUR>")[0].trim();
+           String a_b_d_e_chf = a_b_d_e.split("<CHF>")[1].split("</CHF>")[0].trim();
+
+           assertEquals("3", a_b_d_e_euro);
+           assertEquals("4", a_b_d_e_chf);
+       }
+   }
+   
    public void testXmlExportCompare_Bug_55923() throws Exception {
        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55923.xlsx");
 

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java.orig
(from r1577901, 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.orig?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java.orig&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java&r1=1577901&r2=1577907&rev=1577907&view=diff
==============================================================================
    (empty)



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


Mime
View raw message