]> source.dussan.org Git - poi.git/commitdiff
Pull out http://schemas.openxmlformats.org/spreadsheetml/2006/main to a re-used constant
authorNick Burch <nick@apache.org>
Tue, 23 Feb 2016 22:10:20 +0000 (22:10 +0000)
committerNick Burch <nick@apache.org>
Tue, 23 Feb 2016 22:10:20 +0000 (22:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1731975 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
src/ooxml/java/org/apache/poi/xssf/model/SharedStringsTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java
src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java

index 6ad897c3f2cccf8db37733852f343fd55cf791b5..424ff1b916e3b1db4a3bbbc2a507d6aa97be9f34 100644 (file)
@@ -16,6 +16,8 @@
 ==================================================================== */
 package org.apache.poi.xssf.eventusermodel;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.SPREADSHEETML_NS;
+
 import java.util.LinkedList;
 import java.util.Queue;
 
@@ -41,7 +43,7 @@ import org.xml.sax.helpers.DefaultHandler;
  */
 public class XSSFSheetXMLHandler extends DefaultHandler {
     private static final POILogger logger = POILogFactory.getLogger(XSSFSheetXMLHandler.class);
-    static final String SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
+
     /**
     * These are the different kinds of cells we support.
     * We keep track of the current one between
index 744b48690e956805e9b34987da4e5d68d8bc07d1..6f5d5bc3213f98d67acde7418a98003674e81916 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.xssf.model;
 
 import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+import static org.apache.poi.xssf.usermodel.XSSFRelation.SPREADSHEETML_NS;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,7 +38,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument;
 
-
 /**
  * Table of strings shared across all sheets in a workbook.
  * <p>
@@ -58,9 +58,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument;
  * The shared string table contains all the necessary information for displaying the string: the text, formatting
  * properties, and phonetic properties (for East Asian languages).
  * </p>
- *
- * @author Nick Birch
- * @author Yegor Kozlov
  */
 public class SharedStringsTable extends POIXMLDocumentPart {
 
@@ -94,7 +91,7 @@ public class SharedStringsTable extends POIXMLDocumentPart {
         options.put( XmlOptions.SAVE_INNER );
        options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
        options.put( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE );
-        options.setSaveImplicitNamespaces(Collections.singletonMap("", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
+        options.setSaveImplicitNamespaces(Collections.singletonMap("", SPREADSHEETML_NS));
     }
 
     public SharedStringsTable() {
index e3650921ab6d95b155f97a8a6699190fa8f200e2..de49e8025384dec7cebb1edbe801db5c1d007d38 100644 (file)
@@ -44,7 +44,8 @@ import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.model.ThemesTable;
 
 /**
- *
+ * Defines namespaces, content types and normal file names / naming
+ *  patterns, for the well-known XSSF format parts. 
  */
 public final class XSSFRelation extends POIXMLRelation {
 
@@ -350,6 +351,8 @@ public final class XSSFRelation extends POIXMLRelation {
             "/xl/ctrlProps/ctrlProp#.xml",
             null
     );
+    
+    public static final String SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
 
     private XSSFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
         super(type, rel, defaultName, cls);
index a545fa4b83fab18a073491f3a9d6ba497f3b0697..51a5074f69034fc1887a0fad89c79c0974276b73 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xssf.extractor;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.SPREADSHEETML_NS;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -39,11 +40,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
-/**
- * 
- * @author Roberto Manicardi
- *
- */
 public class TestXSSFImportFromXML {
        
        @Test
@@ -102,7 +98,7 @@ public class TestXSSFImportFromXML {
                String cellC8 = "c8";
                String cellC9 = "c9";
                
-               String testXML = "<ns1:MapInfo xmlns:ns1=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" SelectionNamespaces=\"\">" +
+               String testXML = "<ns1:MapInfo xmlns:ns1=\""+SPREADSHEETML_NS+"\" SelectionNamespaces=\"\">" +
                                                 "<ns1:Schema ID=\""+cellC6+"\" SchemaRef=\"a\" />"+ 
                                                 "<ns1:Schema ID=\""+cellC7+"\" SchemaRef=\"b\" />"+ 
                                                 "<ns1:Schema ID=\""+cellC8+"\" SchemaRef=\"c\" />"+ 
@@ -147,7 +143,7 @@ public class TestXSSFImportFromXML {
                int count = 21;
                
                String testXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"+ 
-                                                "<ns1:table xmlns:ns1=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" id=\""+id+"\" displayName=\""+displayName+"\" ref=\""+ref+"\">"+
+                                                "<ns1:table xmlns:ns1=\""+SPREADSHEETML_NS+"\" id=\""+id+"\" displayName=\""+displayName+"\" ref=\""+ref+"\">"+
                                                 "<ns1:tableColumns count=\""+count+"\" />"+ 
                                                 "</ns1:table>\u0000"; 
                XSSFMap map = wb.getMapInfo().getXSSFMapByName("table_mapping");
index 79a9c2122445fcae55627df3ee4ffb49e546f77c..412095846d0e4bb0b0039dde608a88663d2fb1a7 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.apache.poi.xssf.usermodel.XSSFRelation.SPREADSHEETML_NS;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
@@ -146,7 +147,7 @@ public final class TestXSSFComment extends BaseTestCellComment  {
 
         CTComment ctComment = comment.getCTComment();
         XmlObject[] obj = ctComment.selectPath(
-                "declare namespace w='http://schemas.openxmlformats.org/spreadsheetml/2006/main' .//w:text");
+                "declare namespace w='"+SPREADSHEETML_NS+"' .//w:text");
         assertEquals(1, obj.length);
         assertEquals(TEST_RICHTEXTSTRING, comment.getString().getString());
 
@@ -164,7 +165,7 @@ public final class TestXSSFComment extends BaseTestCellComment  {
         //check the low-level stuff
         comment.setString(richText);
         obj = ctComment.selectPath(
-                "declare namespace w='http://schemas.openxmlformats.org/spreadsheetml/2006/main' .//w:text");
+                "declare namespace w='"+SPREADSHEETML_NS+"' .//w:text");
         assertEquals(1, obj.length);
         assertSame(comment.getString(), richText);
         //check that the rich text is set in the comment