You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by Apache Wiki <wi...@apache.org> on 2013/08/21 19:01:02 UTC

[Xmlbeans Wiki] Update of "XmlBeansFaq" by fx

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xmlbeans Wiki" for change notification.

The "XmlBeansFaq" page has been changed by fx:
https://wiki.apache.org/xmlbeans/XmlBeansFaq?action=diff&rev1=342&rev2=343

Comment:
Added new Question: Why am I getting XmlValueDisconnectedException when I try to change an XmlObject?

    * [[#execQuery|Is execQuery(...) on XmlObject and XmlCursor working?]]
    * [[#xsdConfig|How do I modify the generated interfaces?]]
    * [[#cdataOptions|How do I control CDATA?]]
+   * [[#xmlValueDisconnectedException|Why am I getting XmlValueDisconnectedException when I try to change an XmlObject?]]
  
   * '''[[#somQuestions|Schema Object Model Questions]] '''
    * [[#introToSTS|Is there an introduction document on the XMLBeans Schema Type System?]]
@@ -296, +297 @@

  
  Use CDATA options. Learn more here - CdataOptions.
  
+ <<Anchor(xmlValueDisconnectedException)>> '''Why am I getting !XmlValueDisconnectedException when I try to change an XmlObject?'''
+ 
+ The cause is that the XmlObject is an orphan; i.e., it has become disassociated from the XML store.  This can happen if you get a reference 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 element 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 object!  If you need to keep a deleted object, make a copy before you delete it. For example:
+    
+ {{{
+        LineItem nl = p.getLineItemArray(0).copy();
+        p.removeLineItem(0);
+ }}}
+ 
+ 
  ----
  <<Anchor(somQuestions)>>
  
@@ -330, +341 @@

  
  In a few words, the difference is that !SchemaProperty represents a "flattened", simplified view of the contents of a type, while !SchemaParticle represents a "complete" view including all of the model groups, as defined in Schema. To exemplify, consider the following Schema:
  
+ {{{
- {{{<xs:complexType name="T">
+ <xs:complexType name="T">
  
   . <xs:sequence>
    . <xs:element name="a" type="xs:string"/> <xs:choice>
@@ -338, +350 @@

    </xs:choice>
   </xs:sequence>
  
- </xs:complexType>}}}
+ </xs:complexType>
+ }}}
  
  As you can see, this content mandates an <a> element in the instance, followed by either one or more <a>s or one or more <b>s (a (a+|b+)). The majority of applications would only be interested in what are the names and types of elements allowed inside the content for type "T" and would not care whether there are nested sequeces/choices and the like. As such, they can use {{{SchemaType.getProperties()}}} and they will see two entries, one for element "a" (built by collapsing the two occurences of an "a" element in the Schema) and one for element "b".
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org