users@jaxb.java.net

SV: Re: SAX-like JAXB?

From: Henning Storhaug <Henning.Storhaug_at_fundator.no>
Date: Tue, 20 Jun 2006 10:40:49 +0200

My bad - the collection pointer is ok. Did not take into account .clear() has no effect if nothing is added yet..

________________________________

Fra: Henning Storhaug [mailto:Henning.Storhaug_at_fundator.no]
Sendt: ti 20.06.2006 10:09
Til: users_at_jaxb.dev.java.net
Emne: Re: SV: Re: SAX-like JAXB?


I took a peek into StAX - seems to be excellent for known schema SAX cases, and it gives you writing too. It does not give me the language binding though.
 
I found out the Unmarshaller.Listener events are fired before the child is added to its parent. Not exactly what I want, but I can live with that. Worse it seems like I don't get a direct pointer to the collection - it is increased from time to time even if I clear it. Is there a good reason for that or can it be changed?
 
A solution to this would make JAXB more versatile and perhaps even worth an article :-)
 
- Henning Storhaug
 
________________________________

Fra: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sendt: ma 19.06.2006 19:19
Til: users_at_jaxb.dev.java.net
Emne: Re: SV: Re: SAX-like JAXB?



Henning Storhaug wrote:
>
> I managed to unmarshal transactions only based on the samples/partial-unmarshalling example.
> So I'm half-way there, only the difficult part left now.

Have you considered using StAX? That's much easier than the
partial-unmarshalling sample.

> If I could get the ContentHandler to support an interface like this:
>
> public interface UnmarshalListener {
> /**
> * report new object detected
> * @param object the new object occurrence
> */
>
> public void objectStart(Object object);
> /**
> * report object finished
> * @param object the finished object occurrence
> */
> public void objectEnd(Object object);
> }
>
> Then I can manipulate the graph as I go by caching whatever
> I need and clearing collections as they are populated.. btw,
> is schema validation handled during xml parsing or is it done based
> on the resulting object graph?

See
http://java.sun.com/javaee/5/docs/api/javax/xml/bind/Unmarshaller.Listener.html
for this.

I actually never thought of using it for partial unmarshalling, but I
think you just invented a very interesting approach to the problem.


--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com