Hi there,
I am new in docx4j Java library.
I need it because I have to make text substitutions in Word templates using content controls.
The sample CustomXmlBinding.java is very useful to do this job!
Now I explain you my issue.
I created a docx Word template, adding some content controls.
After that I used Word 2007 Content Control Toolkit tool to bind the controls ( as explained here http://cultivatingcode.com/2010/10/13/generating-word-documents-p2/ ).
Unzipping the original and the new word documents in two folders, and using WinMerge tool to compare them, I saw these changes:
- the file [Content_Types].xml has a new <Ovveride> tag
( in my case: <Override PartName="/customXml/itemProps1.xml" ContentType="application/vnd.openxmlformats-officedocument.customXmlProperties+xml" /> )
- the file /word/_rels/document.xml.rels has a new Relationship
( in my case: <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="../customXml/item1.xml" Id="Rdb0b6908904d430a" /> )
- There is a new directory customXml that contains these files:
- item1.xml that states the content controls
- itemProps1.xml that contains the itemID
- _rels/item1.xml.rels that has 1 relationship to the file /customXml/itemProps1.xml
- the file /word/document.xml added a new <w:dataBinding> tag inside every <w:sdt> tag ( the <w:dataBinding> tag has 2 attributes: w:xpath and w:storeItemID )
I was wondering which is the quickest way to make these steps in Java. Looking into the docx4j source code, I think I have to work with these classes:
- org.docx4j.openpackaging.parts.CustomXmlDataStoragePart.java
- org.docx4j.openpackaging.parts.CustomXmlDataStoragePropertiesPart.java
- org.docx4j.model.datastorage.OpenDoPEHandler.java
The sample CreateDocxWithCustomXml.java is useful, but not enough in my case.
Any help please?
Thanks
Kind Regards
Stefano