Page 1 of 1

Docx4j - OpenDoPE XML bind repeat

PostPosted: Fri Jul 21, 2017 8:45 pm
by Nico
Hi, I'm currently building an app to create word document programmatically.

So I'm using a word docx template, and make a binding with repeat wit the authoring friendly addon.

So the XML sample I use can be something like:
Code: Select all
<data>
  <person>
    <name>John</name>
  </person>
</data>


(Mine is more complex, but for explanation, this one is enough)

And I bind the name on a table cell, and the table is repeated according to the person tag.

But once I bind this template with some real data (using bind method and FLAG_NONE, and the data contains several person tags), the data is only repeated as many times as there is person tags in my sample in Word.
i.e. If I give word a XML with 2 person for the binding definition (of course, only binding the 1st one) and a data to bind (in code) with 4 tags, I will only have 2 rows/table in my resulting word document. (I hope I am clear enough)

So, any idea to still give word a minimal XML template and on binding (in code), make all data correctly repeat?
Thanks.

Re: Docx4j - OpenDoPE XML bind repeat

PostPosted: Fri Jul 21, 2017 9:06 pm
by jason
I think I understand what you are saying, but you'll need to provide sample input docx and data exhibiting the issue.

There are no known problems with basic repeat functionality; please see https://github.com/plutext/docx4j/blob/ ... voice.docx and the corresponding invoice-data.xml for a working example.

Re: Docx4j - OpenDoPE XML bind repeat

PostPosted: Fri Jul 21, 2017 9:41 pm
by Nico
Thanks for you fast reply.

I've made indeed some local test to try to reproduce this, when I finally found the culprit.
I used the preprocess function before my binding, hence, it created the necessary rows according to the sample XML and not the data.

Thanks again, even though if had I searched a little more, I wouldn't had to post this. So let's just hope this post will serve for others if they've done like me.