On 6/22/22 07:41, PJ Fanning wrote:
  I have never come across anyone using POI and docx4j together.
Maybe you would be better off using stackoverflow.com and providing a 
reproducible use case. A larger number of developers can be reached there.


     On Tuesday 21 June 2022, 08:56:51 IST, Anton 
Oellerer<a.oelle...@docu-tools.com>  wrote:
Hello,
The project I am currently working on needs to hand over a .docx document with 
a finished table of contents to an API for pdf conversion.
As far as I figured out, it is currently not possible to generate a finished 
TOC with Apache POI alone, so we decided to try using docx4j + Apache FOP to 
update the TOC after generating the document with Apache POI.
In the first testing runs, we noticed that there are multiple errors in docx4j 
Apache FOP stemming from missing values, which prevent generating a valid 
document.
Those include:

   *  Cannot invoke "org.docx4j.wml.Style$Name.getVal()" because the return value of 
"org.docx4j.wml.Style.getName()" is null
   *  org.docx4j.XmlUtils: java.lang.NullPointerException: Cannot invoke 
"org.w3c.dom.DocumentFragment.getFirstChild()" because "df" is null
   *  java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 2 at 
org.docx4j.model.properties.run.Lang.setXslFO(Lang.java:71)
   *  javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: 
"fo:table-cell" is missing child elements. Required content model: marker* 
(%block;)+ (See position 9:3836)

Do you know whether these results stem from a misconfiguration on our side, or is 
Apache POI -> docx4j simply not a supported use case?
Best regards
Anton Oellerer

It's been quite some time since I last used FOP, but these errors, especially the fo:table-cell, look to me like the document has empty or extraneous "containers".  Maybe injecting a "saxon lint" step between POI output and docx4j would be worthwhile.

Reply via email to