I have to instantiate and populate that objects dynamiccaly, beacuse I 'm writing "Mapper project" , that gets output schemas and data xml as input then create new xml according to output schema , now I have to read output schemas (those objects) dynamically , beacuse this project must be able to map any schemas without konwing anything about schemas , then populate them and finally marshal them in output xml .
--- On Tue, 9/30/08, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
> From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
> Subject: Re: How to fill dynamically JAXB java objects
> To: users_at_jaxb.dev.java.net
> Date: Tuesday, September 30, 2008, 3:11 AM
> You may be able to create an object from one of the JAXB
> generated
> classes by calling clazz.newInstance() after clazz =
> Class.forName(
> "..." ), but what then? I cannot imagine that
> you'll be able to
> provide meaningful data for these objects, just using
> reflection. And,
> even you could do so, what could you do with this object?
>
> Why do you think that you have to do this "dynamic
> element creation"?
>
> There is, of course, the possibility of inspecting (by
> reading the
> JAXB generated annotations) the generated Java classes.
> This will tell
> you which class(es) is (are) XML root elements, and the
> sub-elements
> and attributes of these elements as well. Then, you could
> inspect the
> sub-elements, etc. This is very similar to what JAXB itself
> does to
> learn about the bound XML structure, but this is quite
> complex. (And,
> once more, where would the data for the XML elements come
> from?)
> -W
>
> On Tue, Sep 30, 2008 at 7:48 AM, maliheh shariat
> <malsh20_at_yahoo.com> wrote:
> > Yes I mean the regular way is instantiate from jaxb
> objects and call setter methods but I want to instantiate
> and call setter methods in dynamically (I mean without I
> know the name of object I loop in jaxb objects , instantiate
> it and setting their methods), I know that I must use
> class.forname but I have to know the root element for
> setting another elements in it .
> > do you have any suggestion or better way for doing
> this for me ?
> >
> > Thanks for your attention.
> >
> > Shariat
> >
> > --- On Mon, 9/29/08, Wolfgang Laun
> <wolfgang.laun_at_gmail.com> wrote:
> >
> >> From: Wolfgang Laun
> <wolfgang.laun_at_gmail.com>
> >> Subject: Re: How to fill dynamically JAXB java
> objects
> >> To: users_at_jaxb.dev.java.net
> >> Date: Monday, September 29, 2008, 3:31 AM
> >> What do you mean by "fixed way" and what
> by
> >> "fill dynamically"? Perhaps you
> >> post a Java code snippet of what you call
> "fixed
> >> way".
> >>
> >> Generally speaking, you create an object by a call
> to one
> >> of the methods in
> >> some JAXB generated ObjectFactory class
> >> ("createSomeElement") and then you
> >> call the methods setThisSubElement( ... ) and
> >> setTahtAttribute( ... ) of the
> >> newly generated object. Except for the root
> element, all of
> >> these created
> >> objects have to be entered with setter methods as
> >> sub-elements of their
> >> parent elements.
> >>
> >>
> >> On Sat, Sep 27, 2008 at 9:24 AM, maliheh shariat
> >> <malsh20_at_yahoo.com> wrote:
> >>
> >> > Hi Friends
> >> >
> >> > I created Jaxb java classes and now I want to
> fill
> >> them dynamically , but I
> >> > dont know how I can dynamically fill JAXB
> java objects
> >> (I can do it in fix
> >> > way) ,I must say that their data are in xml
> file to
> >> fill java objects ,
> >> > please help me.
> >> >
> >> > Thanks alot
> >> >
> >> > Shariat
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail:
> >> users-unsubscribe_at_jaxb.dev.java.net
> >> > For additional commands, e-mail:
> >> users-help_at_jaxb.dev.java.net
> >> >
> >> >
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> users-unsubscribe_at_jaxb.dev.java.net
> > For additional commands, e-mail:
> users-help_at_jaxb.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail:
> users-help_at_jaxb.dev.java.net