We are using docx4j-3.3.3 patched with the last corrections on org.docx4j.model.fields.docproperty.DocPropertyResolver.java
We have the attached document where a custom property has been splitted in two w:instrText:
<w:r><w:instrText xml:space="preserve"> DOCPROPERTY <_SUPPLIER_DATA_ELEMENT_1308796842_a0101/> \* </w:instrText></w:r><w:r><w:instrText xml:space="preserve">MERGEFORMAT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:t>Test_row=58_col=34_2015-11-26 16:41:29</w:t></w:r>
when we try to execute
FieldUpdater updater = new FieldUpdater(wordMLPackage);
updater.update(true);
we have a failure because in the method extractInstr of class FieldUpdater there the following check:
if (instructions.size()!=1) {
log.error("TODO DOCPROPERTY field contained complex instruction");
return null;
}
To solve temporary the problem I've done the following modification
if (instructions.size()!=1) {
Iterator<Object> iterator = instructions.iterator();
StringBuilder instructionSB = new StringBuilder();
while(iterator.hasNext()) {
Object o = XmlUtils.unwrap(iterator.next());
if (o instanceof Text) {
instructionSB.append(((Text)o).getValue());
} else {
if(log.isErrorEnabled()) {
log.error("TODO: extract field name from " + o.getClass().getName());
log.error(XmlUtils.marshaltoString(instructions.get(0), true, true));
}
return null;
}
}
return instructionSB.toString();
} else {
// manage single instruction
}
Is this modification correct ?
Does anyone have a better idea on how to solve this problem?
Thanks and best regards
This solution could be a general