// Replace dotx content type with docx
ContentTypeManager ctm = wordMLPackage.getContentTypeManager();
// Get <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml"/>
CTOverride override = ctm.getOverrideContentType().get(new URI("/word/document.xml")); // note this assumption
if (dotx.endsWith("dotm")) // // macro enabled?
{
override.setContentType(org.docx4j.openpackaging.contenttype.ContentTypes.WORDPROCESSINGML_DOCUMENT_MACROENABLED);
} else {
override.setContentType(org.docx4j.openpackaging.contenttype.ContentTypes.WORDPROCESSINGML_DOCUMENT);
}
if (attachTemplate) {
// Create settings part, and init content