Re: Modifying XmlBeans document without XmlValueDisconnectedException?
Nick Burch <[email protected]> Mon, 19 Aug 2013 22:39:40 +0100 (BST)
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 19 Aug 2013, Lott, Christopher M wrote: > We use XmlBeans, code generated from a schema, to read in an XML > instance that conforms to the schema and modify it. Read and validate > work fine; modify is killing me. For example, change the value of an > element, delete an element from a list, etc. I am using Java method > calls like removeMyElement(i) to remove the element at position (i). I > am not using Cursors or any low-level DOM access. I would have expected that to work, but I'm not an xmlbeans expert > We thought it would be convenient to walk thru the document, gather a > list of elements (i.e., references to XmlBeans objects) that need to be > modified or nuked, then iterate over the list changing them. But use of > a cached object reference is where I run into the ditch: I get > XmlValueDisconnectedException. I read that this means the XmlObject has > become disconnected from its underlying store. But I have not discarded > the Document! Are you able to produce a very small unit test (possibly with a dummy schema file) that shows up the problem? People may have more luck in understanding your problem if they can look at some code. If not, at least the "produce a unit test for the bug" part is covered! Nick