You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Ole Matzura <Ol...@mogul.com> on 2005/08/11 21:17:51 UTC

Reordering array problem

Hi all!
 
I'm trying to change the order of the items in an array generated for an unbounded element of a complex type in my schema... ie my schema contains
 
<sequence>
<element name="Foo" type="tns:FooType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
 
and the XmlBeans object for the containing complex type thus has the standard setFooArray methods.. 
 
My problem arises when I want to reorder the array without loosing the existing FooType instances in the array; if I first get the entire array using getFooArray(), reorder it, and then try to set the array with setFooArray( FooType[] ), XmlBeans seems to create a new array of FooType objects which are copies of the ones specified.. my problem arises from the fact that I have bound POJOS to the existing FooType objects, which are suddenly invalidated as "their" FooType objects are no longer valid.. 
 
I've tries using the XmlCuror.moveXml methods instead; they correctly reorder the underlying xml, but the FooType objects bound to the xml elements are not moved in the array and become invalidated as well..
 
So my only option seems to be to recreate my pojos with the new xmlobjects generated when setting the new array as described above.. maybe/hopefully there is a better way though? anybody?
 
any help is greatly appreciated!
 
regards!
 
/Ole