Search code examples
docxdocx4jdoc

Accept tracking changes not removing tables


Currently I am working on a feature using the Docx4J for RShiny, I have everything working right now. The Rshiny recognizes the Java function through the JAR file that I have packaged.

Does anyone know why the Java accept tracking of docx4j is not removing the tables in the word document, even thought the during the tracking changes mode it deleted the table with the text the table still remains?

However when I accept tracking changes in the word document it removes the table too.


Solution

  • Looks like this rule solves the problem:

      <xsl:template match="w:tbl" >
        <xsl:choose>
            <xsl:when test="w:tr[1]/w:trPr/w:del">
                <!-- Word deletes the entire table if this is present -->
            </xsl:when>
            <xsl:otherwise>
                <xsl:copy>
                  <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
            </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    

    https://github.com/plutext/docx4j/commit/ab2261bdd9eaf0487720c0efafd33d68a72ca4c3