Skip to content

v8.3 numPicBullet issue - needs backport #623

Description

@LA15a

docx4j version, Java used

8.3.14 + JAXB-MOXy on Java 8

The issue

Some versions of Word 365 produce a numbering.xml docx4j can’t process. Should docx4j save the resulting document, it cannot be opened by Word again.

Analysis showed the reason to be Word placing an AlternateContent inside a <w:numPicBullet>.

JaxbXmlPartXPathAware.unmarshal(InputStream, boolean), line 594, discovers the alternate content and reduces it to the fallback branch containing a drawing, ignoring the pict in the choice branch. However, the docx4j class for NumPicBullet currently only supports pict. Drawing gets ignored. On resaving, this leaves the <w:numPicBullet w:numPicBulletId="0"/> empty, corrupting the file.

Reproduction

I found this on a document after it got re-saved with Word 365. It contained an embedded image as a numbering symbol. In general, this is how to reproduce this issue: Define numbering with image as symbol. However, even Word 365 does not do this all the time, messing things up.
To speed up things I attached a ready-to-use reproduction maven project containing such a document as well as a Word 2019 counterpart without the issue.

My current solution

Can also be found and enabled in resources folder in the maven repro project

I created a copy of org.docx4j.jaxb.mc-preprocessor.xslt, then below

<xsl:template match="mc:AlternateContent">  

I added an instruction to keep the choice path of numPicBullet (-> the pict docx4j supports) instead of defaulting to fallback.

<xsl:when test="parent::w:numPicBullet">
	<xsl:variable name="message" 
		select="concat('Selecting ', name(mc:Choice/*[1]) )" />  			
	<xsl:variable name="logging" 
		select="java:org.docx4j.utils.XSLTUtils.logWarn($message)" />
	<xsl:copy-of select="mc:Choice/*"/>
</xsl:when>

Then referenced this copy inside docx4j.properties as

docx4j.jaxb.JaxbValidationEventHandler=myworkaround.xslt

Suggestion

Could this xsl:when be integrated into default mc-preprocessor.xslt?

Thank you😊

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions