Page 1 of 1


PostPosted: Tue Apr 14, 2015 5:07 am
by meyerjp3
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

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";

            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);

  , new File(OUTPUT_DOCX), Docx4J.FLAG_NONE);
            System.out.println("Saved: " + OUTPUT_DOCX);

        }catch(IOException ex){
        }catch(Docx4JException ex){


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?



PostPosted: Tue Apr 14, 2015 8:46 pm
by jason
Can you attach your 2015-school-report-template.docx and test xml, or email them to me?


PostPosted: Sat May 30, 2015 1:24 am
by meyerjp3
How do I email you? I can't find your email address.