Page 1 of 1

Docx files with non integer value on w:ind

PostPosted: Tue Aug 29, 2023 11:15 am
by petefc
Hi,

Similar to this issue:
docx-java-f6/problem-with-document-created-by-google-docs-t1802.html

i am seeing values like:
<w:ind w:left="18.899993896484375" w:right="147.41943359375"
w:hanging="7.559967041015625"/>

to solve it quickly set the value of the property docx4j.jaxb.JaxbValidationEventHandler to local version of the mc-preprocessor.xslt and made changes to handle the w:ind attributes.
I added xsl:message output to confirm that my xslt was running and cleaning up the non integer numbers.
I could see the the correct values output in the logs, however my call to:
word.getMainDocumentPart().getContents().getContent();

Still throws a java.lang.NumberFormatException: For input string: "5.9999847"

My assumption was the the mc-preprocessor.xslt would clean all these invalid values and then reload the document content using the output, but this does not appear to be happening.

Is there something else that needs to be enabled to fix this issue?

Thanks

Re: Docx files with non integer value on w:ind

PostPosted: Tue Aug 29, 2023 12:30 pm
by petefc
Apologies, this was an issue in my xlst (rusty). I was not recreating the attribute properly.

Re: Docx files with non integer value on w:ind

PostPosted: Wed Aug 30, 2023 1:24 am
by petefc
FYI this was the fix that was added:

<xsl:template match="@w:left|@w:before|@w:right|@w:firstLine" >
<xsl:attribute name="{concat('w:',local-name())}">
<xsl:value-of select="format-number(., '#')" />
</xsl:attribute>
</xsl:template>

Re: Docx files with non integer value on w:ind

PostPosted: Wed Aug 30, 2023 6:46 am
by jason
No worries, good you handled it. Are you able to share what software is creating the docx files with values like that?