David,

Ralf Joachim wrote:
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.


This approach will work and is generally the best approach for skipping large sections of a document, or handling immediate children of the root node one at a time. Castor's UnmarshalHandler can be obtained from the Unmarshaller (@see Unmashaller#createHandler). Simply forward any events that you want Castor to process to the UnmarshalHandler instance.

Then you can get your object back via the UnmarshalHandler#getObject method.

You will need to understand a little bit of SAX, but it's not that difficult and there are plenty of books and examples available for SAX.


--Keith


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*
<http://www.castor.org/api/org/exolab/castor/xml/Unmarshaller.html#unmarshal(org.exolab.castor.xml.EventProducer)>(EventProducer <http://www.castor.org/api/org/exolab/castor/xml/EventProducer.html> eventProducer)
another solution I guess could be to addapting via set method the
*getContentHandler*
<http://www.castor.org/api/org/exolab/castor/xml/Unmarshaller.html#getContentHandler(org.exolab.castor.xml.UnmarshalHandler)>(UnmarshalHandler <http://www.castor.org/api/org/exolab/castor/xml/UnmarshalHandler.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 <mailto:kvisco-at-intalio.com>
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 <[EMAIL PROTECTED]>/* 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
<http://us.rd.yahoo.com/evt=38382/_ylc=X3oDMTEzNWFva2Y2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMmF1dG9z/*http://autos.yahoo.com/newcars/popular/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]
-------------------------------------------------

Reply via email to