users@jaxb.java.net

Re: Marshal to DOM (using Node.userData)

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 14 Jan 2005 08:10:26 -0800

Vivian Steller wrote:
> is it possible to retrieve the original objects (meaning
> the jaxb generated and unmarshalled with some xml file to
> java objects) after marshalling it to DOM Nodes, maybe via
> getUserData("someKey")??

Not right now. But I think that's an interesting idea. And I think it is
relatively easily doable.

> My problem in general is, that i've a data-structure that
> i want to display in a jtree (therefor dom is quite a nice
> point to start writing some model-adapters) and
> CONCURRENTLY in a jgraph (with anoter model, better to
> adapt the original, jaxb genereated, classes). I want both
> models beeing completly synchronously, thus i don't want
> to generate a new model (by unmarshalling) each time one
> of them changes to keep both up-to-date.

But doing this requires much more than just a simple association,
doesn't it. You somehow have to figure out a way to propagate changes
from DOM to JAXB or JAXB to DOM without throwing away a whole tree, plus
complete change notifications to update their respective views.

I don't think maintaining two data structures in sync is the way you
want to go. If I were you, I'd probably write a wrapper that provides
typed access to DOM (you can make it generic by using
java.lang.reflect.Proxy, for example) with change notifications.

I've been thinking about something like that for some time now. Maybe I
should try to implement that...

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net