Page 1 of 1

UndeclaredNamespaceException

PostPosted: Wed Oct 15, 2014 5:46 am
by aradhira
I have just downloaded v3.2.1 and all dependencies and testing one of the sample program CompareDocuments (src/samples/docx4j/org/docx4j/samples/CompareDocuments.java)

I am getting the following exception

com.topologi.diffx.xml.UndeclaredNamespaceException: The namespace URI "http://schemas.openxmlformats.org/wordprocessingml/2006/main" has not been mapped to any prefix.
at com.topologi.diffx.xml.XMLWriterNSImpl.getQName(XMLWriterNSImpl.java:406)
at com.topologi.diffx.xml.XMLWriterNSImpl.openElement(XMLWriterNSImpl.java:197)
at com.topologi.diffx.event.impl.OpenElementEventNSImpl.toXML(OpenElementEventNSImpl.java:122)
at com.topologi.diffx.format.SmartXMLFormatter.format(SmartXMLFormatter.java:110)
at com.topologi.diffx.Docx4jDriver.formatEventSequence(Docx4jDriver.java:156)
at com.topologi.diffx.Docx4jDriver.diff(Docx4jDriver.java:311)
at org.docx4j.diff.Differencer.diffWorker(Differencer.java:324)
at org.docx4j.diff.Differencer.diff(Differencer.java:302)
at org.docx4j.projects.word.CompareDcouments.main(CompareDcouments.java:101)
java.lang.NullPointerException
at org.docx4j.diff.Differencer.diffWorker(Differencer.java:375)
at org.docx4j.diff.Differencer.diff(Differencer.java:302)
at org.docx4j.projects.word.CompareDcouments.main(CompareDcouments.java:101)

it is failing at line 109: pd.diff(newerBody, olderBody, result, "someone", changeDate,
newerPackage.getMainDocumentPart().getRelationshipsPart(),
olderPackage.getMainDocumentPart().getRelationshipsPart()

any help is appreciated. I did not change any code just trying few sample before using in our project.

thanks in advance.

Re: UndeclaredNamespaceException

PostPosted: Wed Oct 15, 2014 10:33 pm
by jason
I think the following commit should fix this:

https://github.com/plutext/docx4j/commi ... a2fa81ae5f

You can build docx4j yourself to try it, or wait until tomorrow for a nightly build.

Re: UndeclaredNamespaceException

PostPosted: Thu Oct 16, 2014 10:51 pm
by jason
The fix is in http://www.docx4java.org/docx4j/docx4j- ... 141016.jar if you want to try it

Re: UndeclaredNamespaceException

PostPosted: Fri Oct 17, 2014 5:57 am
by aradhira
Thanks Jason. this fixed my issue.
But I got another issue , after further debug it seems , we are expecting a paragraph for everything means all tags must be inside ><w:p> tag.
In the below word xml I have </w:p><w:bookmarkEnd w:id="0"/><w:p. hence it is looking for paraid and failing.

the exception I am getting is
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2927]
Message: http://www.w3.org/TR/1999/REC-xml-names ... paraId&w14
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
at org.docx4j.diff.Differencer.combineAdjacent(Differencer.java:1229)
at org.docx4j.diff.Differencer.diffWorker(Differencer.java:412)
at org.docx4j.diff.Differencer.diff(Differencer.java:302)
at org.docx4j.samples.CompareDocuments.main(CompareDocuments.java:109)

this is happening at int event = reader.next(); in Differencer.java

any help is appreciated.

sample Word xml document:

<w:body><w:p w14:paraId="7CB3A7FC" w14:textId="77777777" w:rsidR="00FA38E0" w:rsidRPr="00FA38E0" w:rsidRDefault="00FA38E0" w:rsidP="00FA38E0"><w:pPr><w:spacing w:before="100" w:beforeAutospacing="1" w:after="100" w:afterAutospacing="1"/><w:rPr><w:b/><w:bCs/><w:color w:val="FF0000"/><w:sz w:val="20"/><w:szCs w:val="20"/><w:u w:val="single"/></w:rPr></w:pPr><w:bookmarkStart w:id="0" w:name="_GoBack"/><w:r w:rsidRPr="00FA38E0"><w:rPr><w:b/><w:bCs/><w:color w:val="FF0000"/><w:sz w:val="20"/><w:szCs w:val="20"/><w:u w:val="single"/></w:rPr><w:t xml:space="preserve">Summary: </w:t></w:r></w:p><w:bookmarkEnd w:id="0"/><w:p w14:paraId="134065C3" w14:textId="77777777" w:rsidR="00FA38E0" w:rsidRDefault="00FA38E0" w:rsidP="00FA38E0"><w:pPr><w:pStyle w:val="NormalWeb"/><w:shd w:val="clear" w:color="auto" w:fill="FFFFFF"/></w:pPr><w:r><w:rPr><w:color w:val="000000"/><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr><w:t>We are currently looking for a Senior Java Developer .This person will work with project teams on their designs to ensure effective implementation of Integration projects, which include full lifecycle design, development, and maintenance of integration interfaces in a SOA environment. Consults and collaborates with a team of senior subject matter experts, enterprise architects, solution architects and security architects in defining the overall integration approaches.</w:t></w:r></w:p>