Page 1 of 1

deepCopy does not work for WordprocessingMLPackage?!

PostPosted: Thu Apr 28, 2011 12:18 am
by Lars
Hi Jason,

today I realised that the XmlUtils.deepCopy(...) method does not work for a WMLPackage.

Code: Select all
java.lang.IllegalArgumentException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: org.docx4j.openpackaging.packages.WordprocessingMLPackage is not known to this context]


Could you tell me why and if it is possible to make it work?

regards,
Lars

Re: deepCopy does not work for WordprocessingMLPackage?!

PostPosted: Thu Apr 28, 2011 1:27 am
by jason
No, it wouldn't. It only works on something which can be marshalled /unmashaled via JAXB; the intended use is for copying the JAXB content of a JAXB XML Part.

To copy a package, you could save it to a stream and read it back.

Or you could copy it part by part.

Or you could convert it to Flat OPC XML (using FlatOpcXmlCreator), then use deepCopy, then convert back again.

Re: deepCopy does not work for WordprocessingMLPackage?!

PostPosted: Tue May 03, 2011 10:47 pm
by Lars
Hi,

I tried to copy the parts of the WMLPackage but these also producess a Illegal Argument Exception. :?:

Could you tell me a little bit more about the FlatOpcXmlCreator. I have had a look into the class and the methods but I'm not sure how to use it and I have no idea how to convert the OPCXML back to a WMLPackage.

regards,
Lars

Re: deepCopy does not work for WordprocessingMLPackage?!

PostPosted: Tue May 03, 2011 11:51 pm
by jason
Hi Lars

Lars wrote:I tried to copy the parts of the WMLPackage but these also producess a Illegal Argument Exception. :?:


Maybe you could expand on what you tried here.

Lars wrote:Could you tell me a little bit more about the FlatOpcXmlCreator. I have had a look into the class and the methods but I'm not sure how to use it and I have no idea how to convert the OPCXML back to a WMLPackage.


Have a look at the 2 samples:

- ExportInPackageFormat
- ImportFromPackageFormat

cheers .. Jason