Add to XmlBeans FAQ re orphaned objects and XmlValueDisconnectedException
"Lott, Christopher M" <[email protected]> Tue, 20 Aug 2013 14:10:27 +0000
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <[email protected]> |
I would like to suggest an addition to page http://wiki.apache.org/xmlbeans=
/XmlBeansFaq but I cannot edit it, so am trying the email list. Please re=
direct me if I'm sending this to the wrong place.=20
Is this Q & A sufficient and clear? Thanks for listening.
Q: Why am I getting XmlValueDisconnectedException when I try to change an X=
mlObject?
A: The most likely cause is that the XmlObject is an orphan; i.e., it has b=
ecome disassociated from the XML store. This can happen if you get a refer=
ence to an object (perhaps by fetching the first item in an array), delete =
the item from the tree (perhaps by calling the array remove method on eleme=
nt 0), and then try to invoke methods on that reference or any of its child=
elements. You cannot even invoke the toString() method on an orphaned obj=
ect! If you need to keep a deleted object, make a copy before you delete i=
t. For example:
LineItem nl =3D LineItem.Factory.parse(p.getLineItemArray(0).=
toString());
p.removeLineItem(0);
Credit this to Paul Gillen and also the people who posted to a thread in 20=
06:
http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200602.mbox/%3C99479=
[email protected]%3E=