- Code: Select all
org.docx4j.openpackaging.exceptions.Docx4JException: No xpathStorageItemId found, does the document contain content controls that are bound?
I am using this code for the binding
- Code: Select all
public void bindDocument(){
String input_DOCX = path + "\\docx\\2015-school-report-template.docx";
String input_XML = path + "\\xml\\test-file.xml";
String OUTPUT_DOCX = path + "\\output\\school1.docx";
try{
WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(input_DOCX));
File inputFile = new File(input_XML);
FileInputStream xmlStream = new FileInputStream(inputFile);
Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_BIND_INSERT_XML & Docx4J.FLAG_BIND_BIND_XML);
Docx4J.save(wordMLPackage, new File(OUTPUT_DOCX), Docx4J.FLAG_NONE);
System.out.println("Saved: " + OUTPUT_DOCX);
}catch(IOException ex){
ex.printStackTrace();
}catch(Docx4JException ex){
ex.printStackTrace();
}
}
Note that some of the content controls have no associated XML part. They will eventually, but not right now. Must every content control have an XPATH? Any ideas of what is causing this error?
Thanks