List Info

Thread: polymorphism




polymorphism
country flaguser name
United States
2007-04-12 16:47:21
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().addNewObjectWrapper();
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"&gt;
  <rol:roleName xmlns:rol="http://schemas.cmp.cisco.com/2006/07/Chameleon/RoleP">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
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )