You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Roman Seidl <ro...@granul.at> on 2005/08/08 17:10:44 UTC

Re: References to subnodes / changes not in parent | Part 2

Dear XMLBeans-Users / Developers,

i run another Test and now found out, that the following test passes:

        UserDocument user = UserDocument.Factory.newInstance();
        user.setUser(UserType.Factory.newInstance());
        UserType ut = user.getUser();
        ut.setEmail("haasnsi");
        ut.setAge(1232);
        ut.setEmail("hansi");
        ut.setFirstname("hias");
        assertEquals(user.getUser().getEmail(), "hansi");

So obviously it only fails to update the parents UserType Document when 
i assign it an the reuse the old reference. Is this documented? Is there 
a way to get around this problem - besides getting the new reference 
from the parent (the questions from the last email persist...)?

thanks!

cheers
roman

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


Re: References to subnodes / changes not in parent | Part 2

Posted by David Jencks <da...@yahoo.com>.
These features are present because xml is a tree whereas javabeans can 
form a directed graph.  The setXXX methods all copy their argument to 
assure that no XmlObject has more than one parent.  I think you want to 
use the addNewXXX methods on the parent object instead of newInstance 
on the object's factory: the add methods create a new subelement that 
is already a child of the parent and avoids copying.

thanks
david jencks

On Aug 8, 2005, at 8:10 AM, Roman Seidl wrote:

> Dear XMLBeans-Users / Developers,
>
> i run another Test and now found out, that the following test passes:
>
>        UserDocument user = UserDocument.Factory.newInstance();
>        user.setUser(UserType.Factory.newInstance());
>        UserType ut = user.getUser();
>        ut.setEmail("haasnsi");
>        ut.setAge(1232);
>        ut.setEmail("hansi");
>        ut.setFirstname("hias");
>        assertEquals(user.getUser().getEmail(), "hansi");
>
> So obviously it only fails to update the parents UserType Document 
> when i assign it an the reuse the old reference. Is this documented? 
> Is there a way to get around this problem - besides getting the new 
> reference from the parent (the questions from the last email 
> persist...)?
>
> thanks!
>
> cheers
> roman
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


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