Page 1 of 1

How do I work around the JAXB bug with refreshing?

PostPosted: Thu Sep 23, 2010 10:51 am
by desau
So - JAXB issue #459 -- how do I work around this?

If I truly need to call xpath, then update, then call xpath again, with the updated XML?

Re: How do I work around the JAXB bug with refreshing?

PostPosted: Thu Sep 23, 2010 1:03 pm
by jason
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.

Re: How do I work around the JAXB bug with refreshing?

PostPosted: Thu Sep 23, 2010 3:26 pm
by desau
Cool - I'll check out TraversalUtil.

I have worked around this by doing my own non-xpath traversal, but there are times when xpath is so much easier. :)

Thanks again!