we have setup a Word-template (using Word 2016) containing nested repeating sections inside tables.
We do not use any OpenDoPE-plugins for this, only standard Word content-controls are assigned from the XML-Pane.
When saving the template after assignment of content-controls and nested repeating sections inside a table (outer repeat is whole table, inner repeat is 3 rows inside the table) the docx4j3.3.5 binding-process works fine, all content gets mapped successfully.
The phenomenon we are facing is, when reopening the template with Word and - even without any changes - resaving it, the internal structure (inside word/document.xml) gets rearranged and any following binding-process fails with ClassCastException inside org.docx4j.model.datastorage.OpenDoPEHandler.processW15Repeat(Object, Map<String, CustomXmlPart>), in detail:
- Code: Select all
// replace its content
SdtElement repeatingItem = (SdtElement)XmlUtils.unwrap(ca.getContent().get(0));
because the retrieved ca.getContent().get(0) represents a org.docx4j.wml.Tr-element instead of the expected SdtElement.
Now my questions are:
1. Did you in any other use-case detect this Word-behaviour?
2. Can't Word re-read it's own files preserving the original structure?
3. Are we mis-using these repeatable-section features, ie. can't this be done with Word content-controls?
Attached you find the originally saved (and working) Word-Template (original_repeating_multi_tablerows.docx) and it's contained document.xml (original_document.xml).
The offending changed document.xml can be produced by opening the Word-template and re-saving the template without changing anything. (I could not upload the xml because of file-size restrictions, which is strange also).
A sample XML input-file for binding is supplied as debug_input_spc.xml.
Please let me know your opinion, any help is greatly appreciated!
Of course I can supply additional information if needed,
kind regards, Martin