Pull out http://schemas.openxmlformats.org/spreadsheetml/2006/main to a re-used constant
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1731975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c58e4fe96c
commit
094e3f68e6
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user