Page 1 of 1

unexpected element Error after upgrade to version 3.3.1

PostPosted: Tue Sep 27, 2016 9:19 pm
by klausT
Hello,

I am experiencing the same issue as already stated at http://www.docx4java.org/forums/docx-java-f6/error-with-big-docx-files-t2403.html:
After an upgrade from version 3.2.2 to 3.3.1 I am getting the following error message:

org.docx4j.XmlUtils (fatalError:1454) - com.sun.istack.internal.SAXParseException2; unexpected element (uri:"http://schemas.openxmlformats.org/wordprocessingml/2006/main", local:"tc"). Expected elements are <{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sdt>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}permEnd>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}permStart>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}customXmlMoveFromRangeEnd>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}customXmlMoveToRangeStart>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}customXmlMoveToRangeEnd>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}del>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}customXmlInsRangeStart>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}moveFromRangeStart>,<{http://schemas.openxmlformats.org/....

It seems as something is wrong with the template.
But as the template wasn't changed and everything was working fine with version 3.2.2
I really wonder how this can be fixed.

Please find attached the complete log file (level = INFO).

Thanks,
Klaus

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Tue Sep 27, 2016 10:37 pm
by jason
From your log, the error is occurring in OpenDoPEIntegrity.

Code: Select all
   at org.docx4j.XmlUtils.transform(XmlUtils.java:1275)
   at org.docx4j.XmlUtils.transform(XmlUtils.java:1100)
   at org.docx4j.model.datastorage.OpenDoPEIntegrity.process(OpenDoPEIntegrity.java:150)
   at org.docx4j.model.datastorage.OpenDoPEIntegrity.process(OpenDoPEIntegrity.java:114)


That specific code hasn't been altered since before 3.2.2

Can you send me the input to that step, or just sample input to the entire process?

BTW When did you move to Java 8?

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Wed Sep 28, 2016 10:24 pm
by klausT
Hi Jason,

Please find attached the input xml plus the template file.

Regarding your question about the Java version:
We've just switched some weeks ago to Java 8.
I've just checked if Java 7 makes any difference but unfortunately,
the issue remains.

Thanks,
Klaus

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Sat Oct 01, 2016 12:33 pm
by jason
This is triggered by https://github.com/plutext/docx4j/commi ... 443af755a2

In other words, telling JaxbValidationEventHandler to fail hard in the event of an error.

In this case, the problem is:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                  </w:tr>

                  <w:sdt>
                    <w:sdtPr>
                      <w:rPr>
                        <w:rFonts w:ascii="Arial" w:cs="Arial" w:hAnsi="Arial"/>
                        <w:b/>
                        <w:sz w:val="14"/>
                        <w:szCs w:val="14"/>
                      </w:rPr>
                      <w:alias w:val="Conditional: OGfX4"/>
                      <w:tag w:val="od:resultConditionFalse=OGfX4_1_0"/>
                      <w:placeholder>
                        <w:docPart w:val="DefaultPlaceholder_1081868574"/>
                      </w:placeholder>
                      <w:id w:val="1386762676"/>
                      <w:lock w:val="sdtContentLocked"/>
                    </w:sdtPr>
                    <w:sdtEndPr>
                      <w:rPr>
                        <w:b w:val="false"/>
                        <w:lang w:val="x-none"/>
                      </w:rPr>
                    </w:sdtEndPr>
                    <w:sdtContent>
                      <w:tc>

 
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


That is, a tc which is not in a tr.

The root cause of this obviously needs to be figured out.

I will investigate further to see whether docx4j's OpenDoPE functionality has caused this, but it may take some days before I get around to this.

It is possible to hide the issue (which the old behaviour did), but content loss may occur. You can hide the issue with setContinue(true) on JaxbValidationEventHandler in OpenDoPEIntegrity, or by skipping the OpenDoPEIntegrity step entirely, but obviously I can't/don't recommend this.

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Mon Oct 03, 2016 5:58 pm
by klausT
Thanks Jason for checking the root cause.
For the time being I will use the old 3.2.2 version.

Klaus

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Sat Oct 08, 2016 12:18 pm
by jason

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Sat Oct 08, 2016 12:24 pm
by jason

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Tue Oct 11, 2016 7:23 pm
by klausT
Thanks Jason for the quick fix!
Can you already tell when a new nightly build will be available?

Thanks,
Klaus

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Tue Oct 11, 2016 7:46 pm
by jason
Hi Klaus, I expect to do it tomorrow.

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Wed Oct 12, 2016 11:12 pm
by jason

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Wed Oct 19, 2016 11:00 pm
by klausT
Thanks Jason for the fix.

Unfortunately, I get now a different error when using the nightly build from October 12.
This is the Stacktrace:

org.docx4j.openpackaging.exceptions.Docx4JException: Problems applying bindings
at org.docx4j.model.datastorage.BindingTraverserXSLT.traverseToBind(BindingTraverserXSLT.java:188)
at org.docx4j.model.datastorage.BindingHandler.applyBindings(BindingHandler.java:259)
at org.docx4j.model.datastorage.BindingHandler.applyBindings(BindingHandler.java:189)
at com.arianim.swingworker.DocxGenerator$1$1.run(DocxGenerator.java:217)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName
at javax.xml.namespace.QName.<init>(Unknown Source)
at javax.xml.namespace.QName.<init>(Unknown Source)
at org.docx4j.model.datastorage.xpathtracker.Histgram.update(Histgram.java:19)
at org.docx4j.model.datastorage.DomToXPathMap.walkTree(DomToXPathMap.java:67)
at org.docx4j.model.datastorage.DomToXPathMap.walkTree(DomToXPathMap.java:61)
at org.docx4j.model.datastorage.DomToXPathMap.map(DomToXPathMap.java:35)
at org.docx4j.model.datastorage.BindingTraverserXSLT.traverseToBind(BindingTraverserXSLT.java:162)


This happens when I call applyBinding()
Code: Select all
final BindingHandler bh = new BindingHandler(wordMLPackage);
                                 bh.applyBindings();


Do you have an idea what could be the root cause?

Thanks,
Klaus

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Thu Oct 20, 2016 12:02 pm
by jason
klausT wrote:java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName


Please try http://www.docx4java.org/docx4j/docx4j- ... 161020.jar

This contains https://github.com/plutext/docx4j/commi ... 149609999a

Re: unexpected element Error after upgrade to version 3.3.1

PostPosted: Fri Oct 21, 2016 6:00 pm
by klausT
This new version is working fine.

Thanks Jason for your prompt support!