David,
 
there's two classes in the Castor sources that implement the EventProducer 
interface, e.g. DomEventProducer
 
http://cvs.castor.codehaus.org/viewrep/castor/castor/src/main/org/exolab/castor/xml/util/DOMEventProducer.java?r=1.1
 
Have a look at how this class is implemented, and how it uses the 
DocumentHandler to push SAX events towards Castor fro the DOM document tree. 

In your case, you'd skip the DOM parsing business, and replace it with code 
that ...

*) uses an XML parser (through the JAXP interfaces) to parse an XML document.
*) implements the DocumentHandler interface, as that's how the XML parser will 
push various events related to the structure of your document to you.
*) Selectively forward those elements to Castor's DocumentHandler that fit your 
requirements.

As a result, Castor will only use those elements that you decide to forward to 
build up an obejct model.

I hope this clarifies a few issues.

Werner Guttmann

________________________________

        From: David [mailto:[EMAIL PROTECTED] 
        Sent: Montag, 20. Februar 2006 10:13
        To: [email protected]
        Subject: RE: [castor-user] How to converto big XML files into java 
object efficiently?
        
        
        Werner and people from the list,
         
        I think too that it should the solution, but there no one example in 
Castor about how to use this interface. I should have to implement the void 
start() method, with no more information. 
         
        This is the unmarshal source code for the EventProducer case:
         
        public Object unmarshal(EventProducer eventProducer)
                throws MarshalException, ValidationException
            {
                UnmarshalHandler handler = createHandler();
                eventProducer.setDocumentHandler(handler);
                try {
                    eventProducer.start();
                }
                catch(org.xml.sax.SAXException sx) {
                 // omitted code
                }
                return handler.getObject();
            } //-- unmarshal(EventProducer)
         
        so internally a unmarshal handler is created, so why the interface 
EventProducer needs to implement the method: setDocumentHandler()????, such 
information at least on the unmarshall process it not used.
         
        so the start() method do everything!!!!, I have no idea about how to 
implement such method, because there is no documetation about it, only this 
comment: "Sets the DocumentHandler to send SAX events to " on the API.
         
        Thanks in advance,
         
        David

        Werner Guttmann <[EMAIL PROTECTED]> wrote:

                David,
                
                In my view, using the unmarshal(EventProducer) method on the 
Umarshaller class migt be an option for you. This way, you could implement your 
own filter(ing) on the events being passed to you by an XML parser of your 
choice, and only forward those events to Castor XML that you are interested in.
                
                Regards
                Werner Guttmann
                
                > -----Original Message-----
                > From: Ralf Joachim [mailto:[EMAIL PROTECTED] 
                > Sent: Sonntag, 19. Februar 2006 23:48
                > To: [email protected]
                > Subject: Re: [castor-user] How to converto big XML files into 
                > java object efficiently?
                > 
                > David, Werner,
                > 
                > I'm quite sure that using a pull parser will not help.
                > 
                > One idea (workaround) that came to my mind after thinking a 
                > bit more about your problem, was to pass the input directly 
                > to a sax parser. When the contenthandler gets called with a 
                > book tag you pass it over to castor to unmarshal it. I'm not 
                > sure if this could work but maybe worse a try.
                > 
                > Having said that I have send Keith a private mail after my 
                > first replay to your mail but I don't know if he is able to 
                > respond soon.
                > 
                > You are right that marketing is also important to open source 
                > projects and I totally agree that documentation of Castor 
                > could be improved a lot and not only on the XML but also the 
                > database side. We are aware of this problem and are trying to 
                > improve things. The recently added howto sections are one 
                > example here, even if they evolve slowly. In addition there 
                > are also some discussions happening in the backgroud to 
                > convice one that started writing a book on castor to continue 
                > his work and to get more people involved in XML. But it isn't 
                > that easy to find people that are willing to spend lots of 
                > their spare time to work on an open source project or 
                > companys that allow their workers to do so.
                > 
                > Regards
                > Ralf
                > 
                > 
                > 
                > Werner Guttmann schrieb:
                > > David,
                > > 
                > > I'll keep this reply quite short, as I have just returned 
from two 
                > > days worth of skiing (yes, even committers need some days 
off, to 
                > > everybody else's suprise ... ;-)). There's been a comment 
on one of 
                > > the existing Jira XML issues mentioning that apparently 
(some) pull 
                > > parser now supports the SAX API.
                > > 
                > > Having said that, I am not sure whether this is valid, and 
                > even if so, 
                > > how integration would look like.
                > > 
                > > More on this tomorrow ...
                > > Werner Guttmann
                > > 
                > > David wrote:
                > > 
                > >>Dear Ralf,
                > >> 
                > >>Thanks for your reply, even you can't help me with my 
problem.
                > >> 
                > >>Anyway I am really suprise that I have no reply for this 
                > problem, that 
                > >>I guess should happend to someone before than me.
                > >> 
                > >>I am not agry about your comment on Open Source project, 
                > there are a 
                > >>lot of open source project and some of them works fine, 
they have a 
                > >>big comunity and people help each other, such as: 
                > Hibernate, Spring, 
                > >>Freemarker, Wikipedia, etc. It is not a question of money, 
it is a 
                > >>question of marketing and business philosofy and having a 
                > good idea, 
                > >>and to really push into the open source market in order to 
                > get a higth 
                > >>popularity (Open Source doesn't mean to not earn money, 
good open 
                > >>source projects, such as Ant sells a lot of copy of good 
                > books for example).
                > >> 
                > >>I give you an example, Ofbiz is an open source project 
since 1997 I 
                > >>guess, but only a few people know about this product. It is 
                > good, but 
                > >>with a bat marketing policy (no consistent documentation, 
                > there is no 
                > >>book, etc) Nevertheless you can get for example Spring with 
                > a bigger 
                > >>popularity and it was founded on 2003!!!. The same 
                > situation apply for 
                > >>SAX etc. Ofbiz is a good product, but because its dificult 
learning 
                > >>curve it has considerable less populary comparing to other 
J2EE 
                > >>frameworks such as Spring, for example.
                > >> 
                > >>Castor is a really good product mainly for binding XML and 
Java 
                > >>Objects (because other competitors are not so complet, the 
                > JDO fetures 
                > >>have a good competitor as Hibernate, :-(, and good 
                > implementation of 
                > >>JDO standard are comercial), but there is no so much 
                > support, there is 
                > >>no forum and on the mailing list there is no so much 
movement. You 
                > >>find on the web a lot of articles and recomendation about 
                > Castor, but 
                > >>the reality is that it there are documented just simple 
                > situation on 
                > >>Castor Web page and on some articles, like parsing a file 
into the 
                > >>java object equivalent, and no more.
                > >> 
                > >>About my problem, I was looking into the source code, but I 
                > am not SAX 
                > >>expert, so I don't find a way to really get wat I want. 
                > There is no so 
                > >>well documented the purpose of EventProduct and also how to 
use it 
                > >>when invoking *unmarshal* 
                > >>
                > r.html#unm
                > >>arshal(org.exolab.castor.xml.EventProducer)>(EventProducer
                > >>
                > er.html> 
                > >>eventProducer) another solution I guess could be to 
                > addapting via set 
                > >>method the
                > >>*getContentHandler*
                > >>
                > r.html#get
                > >>ContentHandler(org.exolab.castor.xml.UnmarshalHandler)>(Unma
                > rshalHandl
                > >>er 
                > >>
                > ndler.html
                > >>> handler) the handler, but I am even not sure about what I 
                > want it is 
                > >>really possible doing with Castor.
                > >> 
                > >>I am waiting for other list members in order to get some 
help abut 
                > >>that, I have tried to contact with Keith Visco 
                > >> but the e-mail on the source 
                > code is wrong.
                > >> 
                > >>If I no get any replay about this problem, I am thinking to 
                > split my 
                > >>original file into smaller file using split unix command 
                > (my original 
                > >>file is a flat file with records, I convert it into XML in 
order to 
                > >>unmarshal), I have no other solution for the moment, 
nevertheless I 
                > >>would prefer to find a solution using just java without any 
trick 
                > >>using unix command.
                > >> 
                > >>Thanks anyway for your help,
                > >> 
                > >>David
                > >>
                > >>
                > >>*/Ralf Joachim /* wrote:
                > >>
                > >> Hi David,
                > >>
                > >> I saw your earlier mail on this topic but did not 
                > respond as I am not
                > >> able to help you with your problem as I am mainly 
                > focused on the JDO
                > >> side of castor and my knowledge on the XML side is 
                > quite limited.
                > >> Please
                > >> be aware that castor is an open source project and that 
                > people working
                > >> at it do not always have the time they wanted to or is 
needed to
                > >> respond
                > >> to every request.
                > >>
                > >> Having said that I share your opinon that what you want 
                > to do should be
                > >> posible. But I am in the same position that you are as 
                > I also don't
                > >> know
                > >> how. I can only suggest you to wait for a response of 
                > one with more
                > >> knowledge on XML things or to take a look at the castor 
                > source yourself
                > >> to find out how it works.
                > >>
                > >> If you at least managed to get things working it would 
                > be great if you
                > >> could write a short howto that I could add to docs to 
                > help others being
                > >> in the same situation.
                > >>
                > >>
                > >> Sorry for any inconvenience
                > >> Ralf
                > >> Castor JDO, committer
                > >>
                > >>
                > >> David schrieb:
                > >> > Dear Members,
                > >> >
                > >> > I have a typical file like this:
                > >> >
                > >> >
                > >> >
                > >> >
                > >> > ...
                > >> >
                > >> >
                > >> >
                > >> > 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 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]
                > >> >
                > >> >
                > >> 
                > --------------------------------------------------------------
                > ----------
                > >> > Relax. Yahoo! Mail virus scanning
                > >> >
                > >> > helps detect nasty viruses!
                > >>
                > >> -------------------------------------------------
                > >> If you wish to unsubscribe from this list, please
                > >> send an empty message to the following address:
                > >>
                > >> [EMAIL PROTECTED]
                > >> -------------------------------------------------
                > >>
                > >>
                > >>------------------------------------------------------------
                > ----------
                > >>--
                > >>
                > >>What are the most popular cars? Find out at Yahoo! Autos 
                > >>zk3MTA3MDc
                > >>2BHNlYwNtYWlsdGFncwRzbGsDMmF1dG9z/*http://autos.yahoo.com/ne
                wcars/popu
                > >>lar/thisweek.html
                > >>
                > > 
                > > 
                > > -------------------------------------------------
                > > If you wish to unsubscribe from this list, please send an 
empty 
                > > message to the following address:
                > > 
                > > [EMAIL PROTECTED]
                > > -------------------------------------------------
                > > 
                > 
                > -------------------------------------------------
                > If you wish to unsubscribe from this list, please send an 
                > empty message to the following address:
                > 
                > [EMAIL PROTECTED]
                > -------------------------------------------------
                > 
                > 
                > 
                
                -------------------------------------------------
                If you wish to unsubscribe from this list, please
                send an empty message to the following address:
                
                [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]
-------------------------------------------------

Reply via email to