ERROR
Posted: Tue Apr 14, 2015 5:07 am
I have a Word template with content controls and a custom XML part. I have used the Word 2007 Content Control Toolkit to bind the XML with the content controls. When I open the document I can see that it has been updated from the XML file. However, if I try to make the binding with code, I get the error message
I am using this code for the binding
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
- 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