Page 1 of 1

Save removes CustomXML

PostPosted: Thu Dec 30, 2010 7:08 am
by c.hoeflake
Hi,

I have a very simple piece of code:
wordMLPackage = WordprocessingMLPackage.load(javaFile);
wordMLPackage.save(toFile);

After the save, the new file has no custom xml in in (checked with the Content Control Toolkit).

Can anyone tell if this is normal? I use version 2.6.0 of docx4j

Re: Save removes CustomXML

PostPosted: Thu Dec 30, 2010 8:20 am
by jason
If your incoming docx does in fact contain a Custom XML part, that is a bug.

Could you please post a simple docx file (renamed as zip) which exhibits the problem?

Re: Save removes CustomXML

PostPosted: Fri Dec 31, 2010 8:36 am
by jason
You might confirm first that the Custom XML part is actually present.

(1) unzip the docx, and confirm; and/or

(2) run the docx4j PartsList sample on it

Re: Save removes CustomXML

PostPosted: Tue Jan 11, 2011 2:49 am
by c.hoeflake
Hi, (sorry for my suspended reply)

I've done the PartsList, the output seems to be ok. Both the test and test-out gives the same output.

The files are attached. test.docx is read and test-out.docx is written. In test.docx, the ContentControl Toolkit sees the custom xml. On the test-out.docx, it says there is no custom xml.

When in docx, getting the CustomXmlDataStoragePart with the databinding ID (.toLowerCase()) of the control results in null.

Re: Save removes CustomXML

PostPosted: Tue Jan 11, 2011 5:59 pm
by jason
The difference between your input (test.docx) and output (test-out.docx) is in the namespace prefix used in the itemProps.xml file.

The input uses ds as the namespace prefix; the output uses ns1.

The Content Control Toolkit's PkgLoader.cs class has a hardcoded dependency on the ds prefix.

docx4j should probably output the same prefix to avoid problems like this; i've just committed a patch which does so.

btw, you know about my Word Add-In, for doing much the same thing as the content control toolkit, but also supporting repeats & conditionals? See the new URL http://www.opendope.org/implementations.html

c.hoeflake wrote:When in docx, getting the CustomXmlDataStoragePart with the databinding ID (.toLowerCase()) of the control results in null.


You mean "When in docx4j", I guess. And something like:

Code: Select all
CustomXmlDataStoragePart part = wmlPkg.getCustomXmlDataStorageParts().get(storeItemId.toLowerCase());


returns null? It shouldn't. You are passing "{e844e250-db0a-431a-bb67-3517237d1b4c}"?

I just tested, so if you continue to have probs; you'll need to post your source code pls.

By the way, your test.docx contains 2 Custom XML parts, both with the same itemID, which is bad. I've just made a commit which will check for this during the load process, and warn you.

hth .. Jason