bug 61296: consolidate some of the ooxml namespace uri copy-paste in POI, prepare to make these usable by downstream libraries like Tika
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1801901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
278a235b08
commit
e8d59d0d7b
@ -31,6 +31,7 @@ import java.util.Map;
|
||||
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
import org.apache.poi.openxml4j.opc.PackageNamespaces;
|
||||
import org.apache.poi.util.DocumentHelper;
|
||||
import org.apache.xmlbeans.SchemaType;
|
||||
import org.apache.xmlbeans.SchemaTypeLoader;
|
||||
@ -50,6 +51,13 @@ public class POIXMLTypeLoader {
|
||||
|
||||
private static ThreadLocal<ClassLoader> classLoader = new ThreadLocal<ClassLoader>();
|
||||
|
||||
// TODO: Do these have a good home like o.a.p.openxml4j.opc.PackageNamespaces and PackageRelationshipTypes?
|
||||
// These constants should be common to all of POI and easy to use by other applications such as Tika
|
||||
private static final String MS_OFFICE_URN = "urn:schemas-microsoft-com:office:office";
|
||||
private static final String MS_EXCEL_URN = "urn:schemas-microsoft-com:office:excel";
|
||||
private static final String MS_WORD_URN = "urn:schemas-microsoft-com:office:word";
|
||||
private static final String MS_VML_URN = "urn:schemas-microsoft-com:vml";
|
||||
|
||||
public static final XmlOptions DEFAULT_XML_OPTIONS;
|
||||
static {
|
||||
DEFAULT_XML_OPTIONS = new XmlOptions();
|
||||
@ -66,17 +74,17 @@ public class POIXMLTypeLoader {
|
||||
map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
|
||||
map.put("http://schemas.openxmlformats.org/drawingml/2006/chart", "c");
|
||||
map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp");
|
||||
map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve");
|
||||
map.put(PackageNamespaces.MARKUP_COMPATIBILITY, "ve");
|
||||
map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m");
|
||||
map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r");
|
||||
map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt");
|
||||
map.put("http://schemas.openxmlformats.org/presentationml/2006/main", "p");
|
||||
map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w");
|
||||
map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne");
|
||||
map.put("urn:schemas-microsoft-com:office:office", "o");
|
||||
map.put("urn:schemas-microsoft-com:office:excel", "x");
|
||||
map.put("urn:schemas-microsoft-com:office:word", "w10");
|
||||
map.put("urn:schemas-microsoft-com:vml", "v");
|
||||
map.put(MS_OFFICE_URN, "o");
|
||||
map.put(MS_EXCEL_URN, "x");
|
||||
map.put(MS_WORD_URN, "w10");
|
||||
map.put(MS_VML_URN, "v");
|
||||
DEFAULT_XML_OPTIONS.setSaveSuggestedPrefixes(Collections.unmodifiableMap(map));
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
|
||||
import org.apache.poi.openxml4j.opc.ContentTypes;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackageNamespaces;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePartName;
|
||||
import org.apache.poi.openxml4j.opc.PackageProperties;
|
||||
@ -46,7 +47,7 @@ public final class PackagePropertiesPart extends PackagePart implements
|
||||
|
||||
public final static String NAMESPACE_DC_URI = "http://purl.org/dc/elements/1.1/";
|
||||
|
||||
public final static String NAMESPACE_CP_URI = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
|
||||
public final static String NAMESPACE_CP_URI = PackageNamespaces.CORE_PROPERTIES;
|
||||
|
||||
public final static String NAMESPACE_DCTERMS_URI = "http://purl.org/dc/terms/";
|
||||
|
||||
|
@ -260,7 +260,7 @@ public class TestRelationships extends TestCase {
|
||||
partB.getRelationship("rId1").getTargetURI().toString());
|
||||
// Check core too
|
||||
assertEquals("/docProps/core.xml",
|
||||
pkg.getRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties").getRelationship(0).getTargetURI().toString());
|
||||
pkg.getRelationshipsByType(PackageRelationshipTypes.CORE_PROPERTIES).getRelationship(0).getTargetURI().toString());
|
||||
|
||||
|
||||
// Add some more
|
||||
|
Loading…
Reference in New Issue
Block a user