David,
Another solution would be to create a Bookstore class with an addBook
method...such as:
public class Bookstore {
public void addBook(Book book) {
// add book to database
}
public Book[] getBooks() {
// return array of Book instances
}
}
You can write a very simple mapping file:
<mapping>
<class name="com.acme.Bookstore">
<field name="book" type="Book" collection="array"
get-method="getBooks" set-method="addBook"/>
</class>
<class name="com.acme.Book">
<map-to xml="book"/>
<field name="..." type="..."/>
...
</class>
</mapping>
Each time Castor encounters the <book/> element it will call the addBook
method. You can then do whatever you want with the book and discard it.
If you're only going to use this for unmarshalling you don't need the
getBooks method.
--Keith
David wrote:
Dear Members,
I have a typical file like this:
<bookstore>
<book> </book>
<book> </book>
...
<book> </book>
</bookstore>
if the file is big enough I can't load the whole book store at once, my
idea is to take one by one each <book> information (or a fixed numbers
of book elements for avoiding overflow), then for example store into
database and then to take the next one, so I want to parse book event,
process it and then to go to the next one. ¿How can we do it with castor?
If I bind the hole bookstore element into BookStore class with million
of books I get Overflow for sure.
It should be a solution where the unmarshall process get each time a
book then you process it (for example stores into database) and go to
the next book without creation a new object for example each time or
doing by a package of certain number of books each time.
Thanks in advance,
David Leal
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
------------------------------------------------------------------------
Relax. Yahoo! Mail virus scanning
<http://us.rd.yahoo.com/mail_us/taglines/virusall/*http://communications.yahoo.com/features.php?page=221>
helps detect nasty viruses!
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------