You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jacob Danner <ja...@gmail.com> on 2007/08/07 19:27:23 UTC

Re: sizeOf

Hi Schalk,
Good question, I had to look into this a little bit :D

In answer to your questions:
Now my question is what exactly does the sizeOf method return each time
it is called?
it counts the elements in the store for the array using something like:
get_store().count_elements(...);
so the result should be the number of items in the array similar to the
.length field on an array

So am I understanding this correctly?
I think so ;)

Does this basically allow the Array to grow dynamically as more investment
objects are added?
Yep, to get into the details of this you will need to understand the xml
store and thats a little beyond my knowledge at the moment. In terms I
understand,  this is required because when maxOccurs="unbounded" is in an
xsd as an array but the 'unbounded' means there is no 'length' set on the
array. This works the same way if maxOccurs="5" but the difference is that
if the array length grows greater than 5 it would fail validation.

Hope this helps clarify things, please let the list know if you have further
questions,
-Jacob Danner




On 7/24/07, Schalk Neethling <sc...@alliedbridge.com> wrote:
>
> Greetings everyone,
>
> I recently inherited a project from another developer and he was using a
> lot of XSD's that was converted to XMLBeans via an Ant task. These were
> then used as schemaDto's.
>
> All this is fine and good and I really like the ease of design and
> automation it brings. One question I have though, in some of the
> XMLBeans there is a method generated that is something like:
>
> sizeOfIvestmentsArray();
>
> Now, he has been using this method as follows:
>
> private ContractNotes(ContractNotes cn) {
>
> Investments investments = Investments.Factory.newInstance();
>
> this.mapInvestments(investments);
>
> cn.addNewInvestments();
> cn.setInvestmentsArray(cn.sizeOfInvestmentsArray - 1, investments);
>
> return cn;
> }
>
> Now my question is what exactly does the sizeOf method return each time
> it is called? Does it basically return 1 the first time which would
> then, used with -1, return index 0 for the Array and then add the
> investment to this position in the Array.
>
> When called again it would return 2, used with -1, it would add the next
> investment at index 1 within the Array etc. etc.
>
> So am I understanding this correctly? Does this basically allow the
> Array to grow dynamically as more investment objects are added?
>
> Looking forward to you input.
>
> Kind Regards,
> Schalk Neethling
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Re: sizeOf

Posted by Schalk Neethling <sc...@alliedbridge.com>.
Thanks a lot Jacob.

Jacob Danner wrote:
> Hi Schalk,
> Good question, I had to look into this a little bit :D
> 
> In answer to your questions:
> Now my question is what exactly does the sizeOf method return each time
> it is called?
> it counts the elements in the store for the array using something like:
> get_store().count_elements(...);
> so the result should be the number of items in the array similar to the
> .length field on an array
> 
> So am I understanding this correctly?
> I think so ;)
> 
> Does this basically allow the Array to grow dynamically as more
> investment objects are added?
> Yep, to get into the details of this you will need to understand the xml
> store and thats a little beyond my knowledge at the moment. In terms I
> understand,  this is required because when maxOccurs="unbounded" is in
> an xsd as an array but the 'unbounded' means there is no 'length' set on
> the array. This works the same way if maxOccurs="5" but the difference
> is that if the array length grows greater than 5 it would fail validation.
> 
> Hope this helps clarify things, please let the list know if you have
> further questions,
> -Jacob Danner
> 
> 
> 
> 
> On 7/24/07, *Schalk Neethling* <schalk@alliedbridge.com
> <ma...@alliedbridge.com>> wrote:
> 
>     Greetings everyone,
> 
>     I recently inherited a project from another developer and he was using a
>     lot of XSD's that was converted to XMLBeans via an Ant task. These were
>     then used as schemaDto's.
> 
>     All this is fine and good and I really like the ease of design and
>     automation it brings. One question I have though, in some of the
>     XMLBeans there is a method generated that is something like:
> 
>     sizeOfIvestmentsArray();
> 
>     Now, he has been using this method as follows:
> 
>     private ContractNotes(ContractNotes cn) {
> 
>     Investments investments = Investments.Factory.newInstance();
> 
>     this.mapInvestments(investments);
> 
>     cn.addNewInvestments();
>     cn.setInvestmentsArray(cn.sizeOfInvestmentsArray - 1, investments);
> 
>     return cn;
>     }
> 
>     Now my question is what exactly does the sizeOf method return each time
>     it is called? Does it basically return 1 the first time which would
>     then, used with -1, return index 0 for the Array and then add the
>     investment to this position in the Array.
> 
>     When called again it would return 2, used with -1, it would add the next
>     investment at index 1 within the Array etc. etc.
> 
>     So am I understanding this correctly? Does this basically allow the
>     Array to grow dynamically as more investment objects are added?
> 
>     Looking forward to you input.
> 
>     Kind Regards,
>     Schalk Neethling
> 
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>     <ma...@xmlbeans.apache.org>
>     For additional commands, e-mail: user-help@xmlbeans.apache.org
>     <ma...@xmlbeans.apache.org>
> 
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 2007/08/06 04:53 PM

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