On Thu, 20 Jan 2005 14:18:01 -0600, Thomas O'Neill <[EMAIL PROTECTED]> wrote:

> I have some XML that contains many objects of the same type.  Like so:
> 
> class tester {
>     private String name;
>     private String age;
> }
> 
> <testers>
>    <tester>
>      <name>Tom</name>
>      <age>24</age>
>    </tester>
>    <tester>
>      <name>Anni</name>
>      <age>23</age>
>    </tester>
> </testsers>
> 
> My question is, how can i set this up so that castor will unmarshall
> this xml to an array of tester objects?  Is this possible? Is there a
> better way to do this?

Tom, 

You need to create the Testers object that allows an array of Tester
objects as well as the utility methods to handle the array. You may
also need to create a mapping descriptor to tell Castor XML how to map
the XML into the Java objects.

The easiest way to handle this is to start by creating an XSD to
represent the object model and then use the Source Generator to
generate the POJOs for the object model. One reason I suggest this is
that the objects generated by the Source Generator will contain all
the needed utility methods and if the object model ever needs to
change, then you just change the XSD and run it through the Source
Generator again.

Bruce 
-- 
perl -e 'print unpack("u30","<0G)[EMAIL 
PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

The Castor Project
http://www.castor.org/

Apache Geronimo
http://geronimo.apache.org/



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to