Page 1 of 1

Is it possible to update xmlns of a docx

PostPosted: Tue Sep 23, 2008 11:50 pm
by neversaydie
I try to place an image at the place of a text. I create a new <w:p> element containing image and replace at the place of previous <w:p> image containg text.I generate the output docx and the format looks perfect in a xml editor.The docx does open in Microsoft word and recognizes a blank picture. The actual image does not appear.
If I edit the original w:document manually, it works. dox4j library has added <v:shapetype xmlns=....>, but that is insufficient.

It seems that original document header namespace should have been like -
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">

But it is [Note that xmlns:v is absent]-
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:ns2="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage" xmlns:ns7="http://schemas.openxmlformats.org/schemaLibrary/2006/main">

Is there any way that I can edit w:document xmlns part exclusively?

Thanks.

Re: Is it possible to update xmlns of a docx

PostPosted: Thu Sep 25, 2008 9:45 pm
by jason
See commented out getPreDeclaredNamespaceUris() attached below from
https://dev.plutext.org/trac/docx4j/bro ... apper.java

You can uncomment that, and add your namespace.

That ought not be necessary, given that the namespace is declared on the relevant element, but this would appear to be a case where Word is picky about where the namespace is declared (picky to the point of not conforming to the XML namespace standard).