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
|