Assuming you are talking about your main document part, you can marshall it, and then unmarshall the result using either:
- Code: Select all
public org.docx4j.wml.Document unmarshal( java.io.InputStream is ) throws JAXBException
public org.docx4j.wml.Document unmarshal(org.w3c.dom.Element el) throws JAXBException
Both of those will re-create the binder.
Not the most efficient, so consider voting for https://jaxb.dev.java.net/issues/show_bug.cgi?id=459
An alternative to using XPath, in current docx4j svn trunk, is TraversalUtil
. It's a generalised way of traversing the org.docx4j.wml.* stuff in main document part, and doing stuff.
See its main method for an example, or the re-written traversal sample
This is used in the content control binding code to resolve repeats. That code used to use XPath; TraversalUtil was my solution to the issue you are facing.