There have been some improvements to OpenDoPE processing in this release, so please test them out.
Get the release candidate at http://www.docx4java.org/docx4j/docx4j-2.7.1-rc1.jar
Improvements include:
[1639] Change static OpenDoPEHandler design to instance-based design, with objective of making it thread-safe.
[1645] When binding, create hyperlinks out of text containing http://
[1653] Handle unwrapping correctly in ShallowTraversor, so JAXBElements stay wrapped, and we don't risk a marshalling exception for any which don't have an @XmlRootElement annotation.
[1658] Word can only resolve an XPath binding which results in an element (as opposed to a boolean, integer, string or node-set). OpenDoPE processing can handle these other results types (some of them anyway).
Up until now, that processing was done in OpenDoPEHandler. Now it is done in BindingHandler and bind.xslt, for consistency with how normal Word XPath bindings are handled by docx4j.
[1662] Bind picture correctly where parent is another content control.
To use OpenDoPE in 2.7.1, your code should look something like:
Using java Syntax Highlighting
// Process conditionals and repeats
OpenDoPEHandler odh = new OpenDoPEHandler(wordMLPackage);
odh.preprocess();
OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(wordMLPackage);
// Apply the bindings
BindingHandler.setHyperlinkStyle("hyperlink");
BindingHandler.applyBindings(wordMLPackage.getMainDocumentPart());
// Strip content controls: you MUST do this
// if you are processing hyperlinks
RemovalHandler rh = new RemovalHandler();
rh.removeSDTs(wordMLPackage, Quantifier.ALL);
SaveToZipFile saver = new SaveToZipFile(wordMLPackage);
saver.save(filepathprefix + "_stripped.docx");
OpenDoPEHandler odh = new OpenDoPEHandler(wordMLPackage);
odh.preprocess();
OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(wordMLPackage);
// Apply the bindings
BindingHandler.setHyperlinkStyle("hyperlink");
BindingHandler.applyBindings(wordMLPackage.getMainDocumentPart());
// Strip content controls: you MUST do this
// if you are processing hyperlinks
RemovalHandler rh = new RemovalHandler();
rh.removeSDTs(wordMLPackage, Quantifier.ALL);
SaveToZipFile saver = new SaveToZipFile(wordMLPackage);
saver.save(filepathprefix + "_stripped.docx");
Parsed in 0.016 seconds, using GeSHi 1.0.8.4
thanks .. Jason