Page 1 of 1

bind an xml to docx repeating row issue

PostPosted: Sat Mar 10, 2018 9:05 am
by Mark S
HI I am trying to run and bind an xml to docx repeating row template. This works but when i try to bind the data to the content controls. It does not seem to be working. I tried inspecting the custom xml in the file that is updated correctly and if i dont remove SDT it works looking at it in Word. But if i remove SDT (which i need to do) it repeats the first row. Same story when I debug the actual JAXB tree in memory its only copying the first row.

I have tried using the other traversal option but no louck there either
below is line :

Docx4J.bind(doc, new FileInputStream(xmlInput), Docx4J.FLAG_BIND_INSERT_XML | Docx4J.FLAG_BIND_BIND_XML | Docx4J.FLAG_BIND_REMOVE_SDT);

Re: bind an xml to docx repeating row issue

PostPosted: Wed Mar 14, 2018 5:49 pm
by jason
Looking at your docx, you are using

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
              <w15:dataBinding w:prefixMappings="" w:xpath="/header[1]/lines[1]/lineitem" w:storeItemID="{6D35D7E8-ED42-4B4A-B4A4-E6B9AACA50D5}"/>
              <w15:repeatingSection/>
 
and
                  <w15:repeatingSectionItem/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


as opposed to OpenDoPE. For my thoughts on that, see https://www.docx4java.org/blog/2015/01/ ... rime-time/

That said, it should work.

I notice that some of your bindings use only w15:dataBinding:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
 <w15:dataBinding w:prefixMappings="" w:xpath="/header[1]/lines[1]/lineitem[1][1]/InterestType[1]" w:storeItemID="{6D35D7E8-ED42-4B4A-B4A4-E6B9AACA50D5}"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


I've just added support for that in binding via XSLT. I'll publish a nightly build shortly.

Re: bind an xml to docx repeating row issue

PostPosted: Thu Mar 15, 2018 1:14 am
by Mark S
Awesome jason thanks for the quick turnaround. I was able to workaround using a Callback on CTSdtCell to bind the data. (as won't be able to use your change until next official release). But will convert to this when it happens. :D