Page 1 of 1

Sample document 'invoice' ill-generated in trunk

PostPosted: Thu May 19, 2011 10:15 pm
by tinne
In contrary to version 2.6.0, the current head version von docx4j.ContentControlBindingExtensions generates an invoice_bound.xml which is not accepted by my version of word 2010 (unknown error at /word/document.xml , line 98, row 0).

This is obviously due to the fact that empty <sdtContent/> elements are not accepted in w:tr/w:sdt: Changing them for <w:sdtContent><w:tc><w:p/></w:tc></w:sdtContent>, the document is working perfectly (interesting enough, changing the first column suffices to "repair" the document, word then omits the second row of the table).

However, compared to the result of the 2.6.0 version processor, still the information regarding the preferred table cell width is lost, so an easy fix by adding another special case to bind.xslt seems to be unreasonable. For the moment, I'd consider binding of sdt cells in trunk as broken.

Re: Sample document 'invoice' ill-generated in trunk

PostPosted: Fri May 20, 2011 1:33 pm
by jason
Thanks for this.

Fixed in http://dev.plutext.org/trac/docx4j/changeset/1501

tinne wrote:still the information regarding the preferred table cell width is lost


If I'm understanding you correctly, the patch addresses this, with

Code: Select all
<!--  preserve existing w:tcPr -->
<xsl:copy-of select="w:sdtContent/w:tc/w:tcPr"/>


cheers .. Jason

Roundtripping Was: Sample document 'invoice' ill-generated i

PostPosted: Fri May 20, 2011 10:45 pm
by tinne
Now, the trunk version builds a bound invoice that works. Unfortunately, I did some further testing (I'd consider these topics advanced and nice-to-have):

When I run new new document 'invoice_bound.xml' through the same process again,
  • The <stdContent/> tags reappear, fixing them as above produces a valid document.
  • The repeat is not duplicated again, there this part can be roundtripped.
  • The conditional deletions removed in the first iteration do not reappear though I had set the references flag to true in the customXml. This is obviously due to the fact that OpenDoPEHandler really, really deletes the section. I thought that maybe be flagging them as deleted text, they might be restored after such an operation. Of course, this restricts the kind of word objects that may be embedded in some way, but might be worth thinking of.

Thank you for the quick reaction to all my posts.

Re: Sample document 'invoice' ill-generated in trunk

PostPosted: Thu Jun 16, 2011 3:24 am
by tinne


Your fix contains a small imprecision: the copy statement for the paragraph properties must be "w:sdtContent/w:tc/w:p/w:pPr", not "w:sdtContent/w:p/w:pPr".

Then again, I'd like the job completed for SDTs which form whole rows or even tables. The applied patch does this, copying all tblPrs and tblGrids resp trPrs. I also added support for copying stdEndPr-Properties.

bind.xslt.patch.txt
Patch for bind.xslt
(3 KiB) Downloaded 299 times


Btw.: Tables also make useful multi-rows, as Word joins neighboring tables automatically.

Re: Sample document 'invoice' ill-generated in trunk

PostPosted: Mon Jun 20, 2011 9:29 am
by jason
Thanks for this Tinne; applied in http://dev.plutext.org/trac/docx4j/changeset/1546