Well, then as far as I can tell, it must be a bug in parsing
from a
DocumentFragment (the return of top.newDomNode() is a doc
frag).
Radu
On Thu, 2007-04-12 at 16:21 -0700, Vinh Nguyen (vinguye2)
wrote:
> Hi Radu,
> Thanks for your help. Here's there updated code:
>
> RoleType role =
RoleDocument.Factory.newInstance().addNewRole();
> role.setRoleName("my role name");
> System.out.println("role:n" + role);
>
> ObjectWrapperType wrapper =
>
ObjectWrapperDocument.Factory.newInstance().addNewObjectWrap
per();
> wrapper.setTop(role);
> System.out.println("wrapper:n" + wrapper);
>
> TopType top = wrapper.getTop();
> System.out.println("top:n" +
top.xmlText());
>
> RoleType role2 =
RoleType.Factory.parse(top.newDomNode());
> System.out.println("role2:n" + role2);
> System.out.println("role2.getRoleName(): " +
role2.getRoleName());
>
> And here's the output:
>
> role:
> <roleName
> xmlns="http://schemas.cmp.cisco.com/2006/07/Chameleon/R
oleP">my role
> name</roleName>
> wrapper:
> <Top xmlns="http://schemas.cmp.cisco.com/2006/07/Chameleon/TopP&quo
t;
> xmlns:rol="http://schemas.cmp.cisco.com/2006/07/Chameleon/Rol
eP">
> <rol:roleName>my role
name</rol:roleName>
> </Top>
> top:
> <rol:roleName
> xmlns:rol="http://schemas.cmp.cisco.com/2006/07/Chameleon/R
oleP">my role
> name</rol:roleName>
> role2:
> <topp:Top
> xmlns:topp="http://schemas.cmp.cisco.com/2006/07/Chameleon/TopP
">
> <rol:roleName
> xmlns:rol="http://schemas.cmp.cisco.com/2006/07/Chameleon/R
oleP">my role
> name</rol:roleName>
> </topp:Top>
> role2.getRoleName(): null
>
>
>
> -----Original Message-----
> From: Radu Preotiuc-Pietro [mailto:radup bea.com]
> Sent: Thursday, April 12, 2007 3:08 PM
> To: user xmlbeans.apache.org
> Subject: Re: polymorphism
>
> I am assuming that going through DOM is a requirement,
otherwise there
> is no need to do it...
>
> Can you add a line
>
> System.out.println("top: " + top.xmlText());
>
> before the line where you do newDomNode() to see what
top would look
> like if serialized to text?
>
> Thanks,
> Radu
>
> On Thu, 2007-04-12 at 14:47 -0700, Vinh Nguyen
(vinguye2) wrote:
> > Hi all,
> > I am trying to use XmlBeans for generating classes
for xsds that have
> > an "inheritence" hierarchy. I may not
be using XmlBeans properly, so
> > any help is appreciated.
> >
> > I have three object types.
> > TopType is a base class for various objects.
> > RoleType extends TopType.
> > ObjectWrapperType stores a TopType and is used for
passing objects in
> > a generic way to/from the server.
> >
> > When I set a RoleType into the ObjectWrapperType,
I later get it out
> > as a TopType and convert to a RoleType, but I
can't get the proper
> > role data.
> >
> > Here's my test code:
> >
> > RoleType role =
RoleDocument.Factory.newInstance().addNewRole();
> > role.setRoleName("my role name");
> > ObjectWrapperType wrapper =
> >
ObjectWrapperDocument.Factory.newInstance().addNewObjectWrap
per();
> > wrapper.setTop(role);
> > TopType top = wrapper.getTop();
> > RoleType role =
RoleType.Factory.parse(top.newDomNode());
> > System.out.println("role:n" +
role.xmlText());
> > System.out.println("role.getRoleName():
" + role.getRoleName());
> >
> > Here's my output:
> >
> > role2:
> > <topp:Top
> > xmlns:topp="http://schemas.cmp.cisco.com/2006/07/Chameleon/TopP
">
> > <rol:roleName
> > xmlns:rol="http://schemas.cmp.cisco.com/2006/07/Chameleon/R
oleP">my
> > role name</rol:roleName>
> > </topp:Top>
> > role2.getRoleName(): null
> >
> > I can clearly see that the final RoleType has
data, but I can't get
> > data out of it. Perhaps I am not doing this the
right way?
> > -Vinh
>
> Notice: This email message, together with any
attachments, may contain
> information of BEA Systems, Inc., its subsidiaries
and affiliated
> entities, that may be confidential, proprietary,
copyrighted and/or
> legally privileged, and is intended solely for the use
of the individual
> or entity named in this message. If you are not the
intended recipient,
> and have received this message in error, please
immediately return this
> by email and then delete it.
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> For additional commands, e-mail: user-help xmlbeans.apache.org
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
> For additional commands, e-mail: user-help xmlbeans.apache.org
>
Notice: This email message, together with any attachments,
may contain information of BEA Systems, Inc., its
subsidiaries and affiliated entities, that may be
confidential, proprietary, copyrighted and/or legally
privileged, and is intended solely for the use of the
individual or entity named in this message. If you are not
the intended recipient, and have received this message in
error, please immediately return this by email and then
delete it.
------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: user-help xmlbeans.apache.org
|