- Code: Select all
package myartifact;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.apache.log4j.BasicConfigurator;
public class HelloMavenCentral {
public static void main(String[] args) throws Exception {
BasicConfigurator.configure();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
String filename = "C:\\Users\\Mike\\Desktop\\My.docx";
wordMLPackage.load(new java.io.File(filename) );
}
}
Bombs out trying to find the "officeDocument" relationship type. There is a hard coded check for:
http://schemas.openxmlformats.org/offic ... ceDocument
but what appears in the relationship specification for the actual document is:
http://purl.oclc.org/ooxml/officeDocume ... ceDocument
Here is the problematic code:
- Code: Select all
package org.docx4j.openpackaging;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.parts.relationships.RelationshipsPart;
import org.docx4j.relationships.Relationship;
public class PackageRelsUtil {
public static String getNameOfMainPart(RelationshipsPart packageRels) throws Docx4JException {
// find rel of type officeDocument
for (Relationship rel : packageRels.getRelationships().getRelationship() ) {
if (rel.getType().equals(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") ) {
return rel.getTarget();
}
}
throw new Docx4JException("No relationship of type officeDocument");
}
}
Let me know if there is anything I can do to avoid this.
Thanks.